Skip to content

Commit 93c8529

Browse files
committed
Merge branch '2.x'
* 2.x: make LanguageMap countable
2 parents b99c3dc + c444f9e commit 93c8529

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

src/Definition.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,15 @@ public function equals(Definition $definition)
219219
return false;
220220
}
221221

222-
if (!is_array($this->name) xor !is_array($definition->name)) {
222+
if (null !== $this->name xor null !== $definition->name) {
223223
return false;
224224
}
225225

226-
if (!is_array($this->description) xor !is_array($definition->description)) {
226+
if (null !== $this->description xor null !== $definition->description) {
227227
return false;
228228
}
229229

230-
if (is_array($this->name)) {
230+
if (null !== $this->name) {
231231
foreach ($this->name as $language => $value) {
232232
if (!isset($definition->name[$language])) {
233233
return false;
@@ -239,7 +239,7 @@ public function equals(Definition $definition)
239239
}
240240
}
241241

242-
if (is_array($this->description)) {
242+
if (null !== $this->description) {
243243
foreach ($this->description as $language => $value) {
244244
if (!isset($definition->description[$language])) {
245245
return false;

src/LanguageMap.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @author Christian Flothmann <[email protected]>
1818
*/
19-
final class LanguageMap implements \ArrayAccess
19+
final class LanguageMap implements \ArrayAccess, \Countable
2020
{
2121
private $map;
2222

@@ -104,6 +104,11 @@ public function offsetUnset($languageTag)
104104
throw new \LogicException('Entries of a language map cannot be removed.');
105105
}
106106

107+
public function count()
108+
{
109+
return count($this->map);
110+
}
111+
107112
public function equals(LanguageMap $languageMap)
108113
{
109114
if (count($this->map) !== count($languageMap->map)) {

src/Verb.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,25 @@ public function equals(Verb $verb)
7575
return false;
7676
}
7777

78-
if (!is_array($this->display) xor !is_array($verb->display)) {
78+
if (null === $this->display && null === $verb->display) {
79+
return true;
80+
}
81+
82+
if (null !== $this->display xor null !== $verb->display) {
7983
return false;
8084
}
8185

8286
if (count($this->display) !== count($verb->getDisplay())) {
8387
return false;
8488
}
8589

86-
if (is_array($this->display)) {
87-
foreach ($this->display as $language => $value) {
88-
if (!isset($verb->display[$language])) {
89-
return false;
90-
}
90+
foreach ($this->display as $language => $value) {
91+
if (!isset($verb->display[$language])) {
92+
return false;
93+
}
9194

92-
if ($value !== $verb->display[$language]) {
93-
return false;
94-
}
95+
if ($value !== $verb->display[$language]) {
96+
return false;
9597
}
9698
}
9799

0 commit comments

Comments
 (0)