Skip to content

Commit 61a6aa2

Browse files
authored
Merge pull request #15 from LearningLocker/issue/14
Make validateIdentifiers a truthy experience in both Agent and Group
2 parents 3b6a473 + 43585f0 commit 61a6aa2

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/Agent.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@ protected function identifierError($used_identifiers) {
3434
}
3535

3636
protected function validateIdentifiers($used_identifiers) {
37-
return $used_identifiers !== 1;
37+
return $used_identifiers === 1;
3838
}
3939

4040
public function validate() {
4141
$errors = $this->validateTypedElement();
4242

4343
// Gets the used identifiers.
4444
$used_identifiers = $this->countIdentifiers();
45+
$hasOneIdent = $this->validateIdentifiers($used_identifiers);
4546

4647
// Checks that only one identifier is used.
47-
if ($this->validateIdentifiers($used_identifiers)) {
48+
if (!$hasOneIdent) {
4849
$errors[] = new Error($this->identifierError($used_identifiers));
4950
}
5051

src/Group.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ protected function identifierError($used_identifiers) {
1313
}
1414

1515
protected function validateIdentifiers($used_identifiers) {
16-
$members = $this->getPropValue('member') ?: null;
17-
$validateIdentifiers = parent::validateIdentifiers($used_identifiers);
18-
$validateMembers = $members === null || count($members) === 0;
19-
return $validateIdentifiers && $validateMembers;
16+
$members = $this->getPropValue('member');
17+
$hasOneIdent = parent::validateIdentifiers($used_identifiers);
18+
$hasMembers = !is_null($members) && count($members) > 0;
19+
return $hasOneIdent || (!$hasOneIdent && $hasMembers);
2020
}
2121
}

0 commit comments

Comments
 (0)