本文整理匯總了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);
}