From 1ad893972f7edbca0a5bddb71d9278e27ff9e6f2 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 12 Jun 2018 13:36:03 -0400 Subject: [PATCH] Code simplification. --- .../src/VuFind/Search/Solr/ResultsFactory.php | 4 +--- .../VuFind/Search/Solr/SpellingProcessor.php | 24 +++++++------------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/module/VuFind/src/VuFind/Search/Solr/ResultsFactory.php b/module/VuFind/src/VuFind/Search/Solr/ResultsFactory.php index 474f6944a95..5eea28ca728 100644 --- a/module/VuFind/src/VuFind/Search/Solr/ResultsFactory.php +++ b/module/VuFind/src/VuFind/Search/Solr/ResultsFactory.php @@ -59,10 +59,8 @@ class ResultsFactory extends \VuFind\Search\Results\ResultsFactory ) { $solr = parent::__invoke($container, $requestedName, $options); $config = $container->get('VuFind\Config\PluginManager')->get('config'); - $spellConfig = isset($config->Spelling) - ? $config->Spelling : null; $solr->setSpellingProcessor( - new \VuFind\Search\Solr\SpellingProcessor($spellConfig) + new \VuFind\Search\Solr\SpellingProcessor($config->Spelling ?? null) ); return $solr; } diff --git a/module/VuFind/src/VuFind/Search/Solr/SpellingProcessor.php b/module/VuFind/src/VuFind/Search/Solr/SpellingProcessor.php index c8dc0339af0..03720d3fbc7 100644 --- a/module/VuFind/src/VuFind/Search/Solr/SpellingProcessor.php +++ b/module/VuFind/src/VuFind/Search/Solr/SpellingProcessor.php @@ -47,21 +47,21 @@ class SpellingProcessor * * @var int */ - protected $spellingLimit = 3; + protected $spellingLimit; /** * Spell check words with numbers in them? * * @var bool */ - protected $spellSkipNumeric = true; + protected $spellSkipNumeric; /** * Offer expansions on terms as well as basic replacements? * * @var bool */ - protected $expand = true; + protected $expand; /** * Show the full modified search phrase on screen rather then just the suggested @@ -69,7 +69,7 @@ class SpellingProcessor * * @var bool */ - protected $phrase = false; + protected $phrase; /** * Constructor @@ -78,18 +78,10 @@ class SpellingProcessor */ public function __construct($config = null) { - if (isset($config->limit)) { - $this->spellingLimit = $config->limit; - } - if (isset($config->skip_numeric)) { - $this->spellSkipNumeric = $config->skip_numeric; - } - if (isset($config->expand)) { - $this->expand = $config->expand; - } - if (isset($config->phrase)) { - $this->phrase = $config->phrase; - } + $this->spellingLimit = $config->limit ?? 3; + $this->spellSkipNumeric = $config->skip_numeric ?? true; + $this->expand = $config->expand ?? true; + $this->phrase = $config->phrase ?? false; } /** -- GitLab