Skip to content

Commit e7e238c

Browse files
authored
Prevent exceptions when different cased idioms.
1 parent b81dc26 commit e7e238c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Analyzer.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ public function getSentiment($text)
170170

171171
$text_no_emoji = '';
172172
$prev_space = true;
173-
174-
foreach($this->str_split_unicode($text) as $unichr ) {
173+
174+
foreach($this->str_split_unicode($text) as $unichr ) {
175175
if (array_key_exists($unichr, $this->emojis)) {
176176
$description = $this->emojis[$unichr];
177177
if (!($prev_space)) {
@@ -384,8 +384,9 @@ public function _idioms_check($wordInContext, $valence)
384384
$sequences = [$onezero, $twoonezero, $twoone, $threetwoone, $threetwo];
385385

386386
foreach ($sequences as $seq) {
387-
if (array_key_exists(strtolower($seq), Config::SPECIAL_CASE_IDIOMS)) {
388-
$valence = Config::SPECIAL_CASE_IDIOMS[$seq];
387+
$key = strtolower($seq);
388+
if (array_key_exists($key, Config::SPECIAL_CASE_IDIOMS)) {
389+
$valence = Config::SPECIAL_CASE_IDIOMS[$key];
389390
break;
390391
}
391392

0 commit comments

Comments
 (0)