Open unicodeveloper opened 9 years ago
public function find(DictStore $dictStore, $slang) { $dictionary = $dictStore->dictData; $checkSlangExists = $this->getIndex($dictionary, $slang); if ($checkSlangExists === false) { return false; } else { $slangIndex = $checkSlangExists; $slang = []; $slang['index'] = $slangIndex; $slang['meaning'] = $dictionary[$slangIndex]['description']; $slang['example'] = $dictionary[$slangIndex]['sample-sentence']; return $slang; } }
$slang = []; $slang['index'] = $slangIndex; $slang['meaning'] = $dictionary[$slangIndex]['description']; $slang['example'] = $dictionary[$slangIndex]['sample-sentence']; return $slang;
should be abstracted into another function and then called here.
if ($checkSlangExists === false) { return false; }
is like saying check if false === false return false :flushed:
false === false
false
You should throw an exception instead, something like
if( ! $checkSlangExists ) { throw NotFoundException("blah..blah..blah"); } else { $this->theNewSlangFunctionYouCreated(); }
should be abstracted into another function and then called here.
is like saying check if
false === false
returnfalse
:flushed:You should throw an exception instead, something like