Skip to content

Commit

Permalink
Formatting changes and updating class references from strings to use …
Browse files Browse the repository at this point in the history
…php ::class const
  • Loading branch information
TomLingham committed Dec 23, 2015
1 parent 70d102f commit 28b0e04
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
5 changes: 5 additions & 0 deletions src/SearchDrivers/BaseSearchDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
abstract class BaseSearchDriver implements SearchDriverInterface
{
protected $table;

protected $columns;

protected $searchFields;

protected $searchString;

protected $relevanceFieldName;

protected $query;

/**
Expand Down
18 changes: 9 additions & 9 deletions src/SearchDrivers/FuzzySearchDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ class FuzzySearchDriver extends BaseSearchDriver
* @var array
*/
protected $matchers = [
'TomLingham\Searchy\Matchers\ExactMatcher' => 100,
'TomLingham\Searchy\Matchers\StartOfStringMatcher' => 50,
'TomLingham\Searchy\Matchers\AcronymMatcher' => 42,
'TomLingham\Searchy\Matchers\ConsecutiveCharactersMatcher' => 40,
'TomLingham\Searchy\Matchers\StartOfWordsMatcher' => 35,
'TomLingham\Searchy\Matchers\StudlyCaseMatcher' => 32,
'TomLingham\Searchy\Matchers\InStringMatcher' => 30,
'TomLingham\Searchy\Matchers\TimesInStringMatcher' => 8,
];
\TomLingham\Searchy\Matchers\ExactMatcher::class => 100,
\TomLingham\Searchy\Matchers\StartOfStringMatcher::class => 50,
\TomLingham\Searchy\Matchers\AcronymMatcher::class => 42,
\TomLingham\Searchy\Matchers\ConsecutiveCharactersMatcher::class => 40,
\TomLingham\Searchy\Matchers\StartOfWordsMatcher::class => 35,
\TomLingham\Searchy\Matchers\StudlyCaseMatcher::class => 32,
\TomLingham\Searchy\Matchers\InStringMatcher::class => 30,
\TomLingham\Searchy\Matchers\TimesInStringMatcher::class => 8,
];
}
2 changes: 1 addition & 1 deletion src/SearchDrivers/LevenshteinSearchDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class LevenshteinSearchDriver extends BaseSearchDriver
* @var array
*/
protected $matchers = [
'TomLingham\Searchy\Matchers\LevenshteinMatcher' => 100,
\TomLingham\Searchy\Matchers\LevenshteinMatcher::class => 100,
];
}
6 changes: 3 additions & 3 deletions src/SearchDrivers/SimpleSearchDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class SimpleSearchDriver extends BaseSearchDriver
* @var array
*/
protected $matchers = [
'TomLingham\Searchy\Matchers\ExactMatcher' => 100,
'TomLingham\Searchy\Matchers\StartOfStringMatcher' => 50,
'TomLingham\Searchy\Matchers\InStringMatcher' => 30,
\TomLingham\Searchy\Matchers\ExactMatcher::class => 100,
\TomLingham\Searchy\Matchers\StartOfStringMatcher::class => 50,
\TomLingham\Searchy\Matchers\InStringMatcher::class => 30,
];
}
18 changes: 15 additions & 3 deletions src/SearchyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,21 @@ public function register()
*/
public function registerSearchy()
{
$this->app->bindShared('searchy', function ($app) {
return new SearchBuilder($app['config']);
});
// Laravel <= 5.1
$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);
}
}

/**
Expand Down

0 comments on commit 28b0e04

Please sign in to comment.