本文整理汇总了PHP中Composer\Repository\ArrayRepository::search方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayRepository::search方法的具体用法?PHP ArrayRepository::search怎么用?PHP ArrayRepository::search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Repository\ArrayRepository
的用法示例。
在下文中一共展示了ArrayRepository::search方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSearchWithPackageType
public function testSearchWithPackageType()
{
$repo = new ArrayRepository();
$repo->addPackage($this->getPackage('foo', '1', 'Composer\\Package\\CompletePackage'));
$repo->addPackage($this->getPackage('bar', '1', 'Composer\\Package\\CompletePackage'));
$package = $this->getPackage('foobar', '1', 'Composer\\Package\\CompletePackage');
$package->setType('composer-plugin');
$repo->addPackage($package);
$this->assertSame(array(array('name' => 'foo', 'description' => null)), $repo->search('foo', RepositoryInterface::SEARCH_FULLTEXT, 'library'));
$this->assertEmpty($repo->search('bar', RepositoryInterface::SEARCH_FULLTEXT, 'package'));
$this->assertSame(array(array('name' => 'foobar', 'description' => null)), $repo->search('foo', 0, 'composer-plugin'));
}
示例2: search
/**
* {@inheritDoc}
*/
public function search($query, $mode = 0)
{
$this->loadRootServerFile();
if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) {
$url = str_replace('%query%', $query, $this->searchUrl);
$hostname = parse_url($url, PHP_URL_HOST) ?: $url;
$json = $this->rfs->getContents($hostname, $url, false);
$results = JsonFile::parseJson($json, $url);
return $results['results'];
}
if ($this->hasProviders()) {
$results = array();
$regex = '{(?:' . implode('|', preg_split('{\\s+}', $query)) . ')}i';
foreach ($this->getProviderNames() as $name) {
if (preg_match($regex, $name)) {
$results[] = array('name' => $name);
}
}
return $results;
}
return parent::search($query, $mode);
}