Skip to content

Commit

Permalink
Fixed text and logic
Browse files Browse the repository at this point in the history
  • Loading branch information
SecondeJK committed Sep 12, 2024
1 parent a1fb169 commit cb8c778
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/Voice/VoiceObjects/AdvancedMachineDetection.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ protected function isValidTimeout(int $beepTimeout): bool

public function fromArray(array $data): static
{
$this->isArrayValid($data);
if (!$this->isArrayValid($data)) {
throw new \InvalidArgumentException('Invalid payload');
};

$this->behaviour = $data['behaviour'];
$this->mode = $data['mode'];
Expand Down Expand Up @@ -102,8 +104,12 @@ protected function isArrayValid(array $data): bool
return false;
}

return $this->isValidBehaviour($data['behaviour'])
|| $this->isValidMode($data['mode'])
|| $this->isValidTimeout($data['beep_timeout']);
if ($this->isValidBehaviour($data['behaviour'])
&& $this->isValidMode($data['mode'])
&& $this->isValidTimeout($data['beep_timeout'])) {
return true;
};

return false;
}
}
2 changes: 1 addition & 1 deletion test/Voice/VoiceObjects/AdvancedMachineDetectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testValidBeepTimeoutRange()
public function testWillRenderDefault()
{
$amd = new AdvancedMachineDetection('hangup', 100, 'default');
$this->assertEquals('default', $amd->toArray()['default']);
$this->assertEquals('default', $amd->toArray()['mode']);
}

public function testToArray()
Expand Down

0 comments on commit cb8c778

Please sign in to comment.