Skip to content

Commit 0a10375

Browse files
author
Sven Hagemann
committed
Refactored indexNewWords
Added typehints, strict type checking, and removed else code-flow
1 parent 89a3a61 commit 0a10375

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/Caxy/HtmlDiff/HtmlDiff.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class HtmlDiff extends AbstractDiff
1818
* @var array
1919
*/
2020
protected $newIsolatedDiffTags;
21+
2122
/**
2223
* @var array
2324
*/
@@ -116,18 +117,20 @@ public function build()
116117
return $this->content;
117118
}
118119

119-
protected function indexNewWords()
120+
protected function indexNewWords() : void
120121
{
121-
$this->wordIndices = array();
122+
$this->wordIndices = [];
123+
122124
foreach ($this->newWords as $i => $word) {
123-
if ($this->isTag($word)) {
125+
if ($this->isTag($word) === true) {
124126
$word = $this->stripTagAttributes($word);
125127
}
126-
if (isset($this->wordIndices[ $word ])) {
127-
$this->wordIndices[ $word ][] = $i;
128-
} else {
129-
$this->wordIndices[ $word ] = array($i);
128+
129+
if (isset($this->wordIndices[$word]) === false) {
130+
$this->wordIndices[$word] = [];
130131
}
132+
133+
$this->wordIndices[$word][] = $i;
131134
}
132135
}
133136

0 commit comments

Comments
 (0)