Formatting changes and updating class references from strings to use php ::class const

This commit is contained in:
Tom Lingham
2015-12-23 11:24:22 +00:00
parent 70d102f8bf
commit 28b0e04bb2
5 changed files with 33 additions and 16 deletions

View File

@ -7,10 +7,15 @@ use TomLingham\Searchy\Interfaces\SearchDriverInterface;
abstract class BaseSearchDriver implements SearchDriverInterface abstract class BaseSearchDriver implements SearchDriverInterface
{ {
protected $table; protected $table;
protected $columns; protected $columns;
protected $searchFields; protected $searchFields;
protected $searchString; protected $searchString;
protected $relevanceFieldName; protected $relevanceFieldName;
protected $query; protected $query;
/** /**

View File

@ -8,13 +8,13 @@ class FuzzySearchDriver extends BaseSearchDriver
* @var array * @var array
*/ */
protected $matchers = [ protected $matchers = [
'TomLingham\Searchy\Matchers\ExactMatcher' => 100, \TomLingham\Searchy\Matchers\ExactMatcher::class => 100,
'TomLingham\Searchy\Matchers\StartOfStringMatcher' => 50, \TomLingham\Searchy\Matchers\StartOfStringMatcher::class => 50,
'TomLingham\Searchy\Matchers\AcronymMatcher' => 42, \TomLingham\Searchy\Matchers\AcronymMatcher::class => 42,
'TomLingham\Searchy\Matchers\ConsecutiveCharactersMatcher' => 40, \TomLingham\Searchy\Matchers\ConsecutiveCharactersMatcher::class => 40,
'TomLingham\Searchy\Matchers\StartOfWordsMatcher' => 35, \TomLingham\Searchy\Matchers\StartOfWordsMatcher::class => 35,
'TomLingham\Searchy\Matchers\StudlyCaseMatcher' => 32, \TomLingham\Searchy\Matchers\StudlyCaseMatcher::class => 32,
'TomLingham\Searchy\Matchers\InStringMatcher' => 30, \TomLingham\Searchy\Matchers\InStringMatcher::class => 30,
'TomLingham\Searchy\Matchers\TimesInStringMatcher' => 8, \TomLingham\Searchy\Matchers\TimesInStringMatcher::class => 8,
]; ];
} }

View File

@ -8,6 +8,6 @@ class LevenshteinSearchDriver extends BaseSearchDriver
* @var array * @var array
*/ */
protected $matchers = [ protected $matchers = [
'TomLingham\Searchy\Matchers\LevenshteinMatcher' => 100, \TomLingham\Searchy\Matchers\LevenshteinMatcher::class => 100,
]; ];
} }

View File

@ -8,8 +8,8 @@ class SimpleSearchDriver extends BaseSearchDriver
* @var array * @var array
*/ */
protected $matchers = [ protected $matchers = [
'TomLingham\Searchy\Matchers\ExactMatcher' => 100, \TomLingham\Searchy\Matchers\ExactMatcher::class => 100,
'TomLingham\Searchy\Matchers\StartOfStringMatcher' => 50, \TomLingham\Searchy\Matchers\StartOfStringMatcher::class => 50,
'TomLingham\Searchy\Matchers\InStringMatcher' => 30, \TomLingham\Searchy\Matchers\InStringMatcher::class => 30,
]; ];
} }

View File

@ -26,9 +26,21 @@ class SearchyServiceProvider extends ServiceProvider
*/ */
public function registerSearchy() public function registerSearchy()
{ {
$this->app->bindShared('searchy', function ($app) { // Laravel <= 5.1
return new SearchBuilder($app['config']); $closure = function ($app) {
}); return new SearchBuilder( $app['config'] );
};
if ( method_exists($this->app, 'bindShared') )
{
$this->app->bindShared('searchy', $closure);
}
// Laravel 5.2 Goodness :)
else {
$this->app->singleton('searchy', $closure);
}
} }
/** /**