import axiom without dependency on symfony console
Some checks failed
abc-api/abcParser/pipeline/head There was a failure building this commit
Some checks failed
abc-api/abcParser/pipeline/head There was a failure building this commit
This commit is contained in:
29
axiom_src/Atoms/IntegerAtom.php
Normal file
29
axiom_src/Atoms/IntegerAtom.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Atoms;
|
||||
|
||||
use Enzyme\Axiom\Exceptions\AtomException;
|
||||
|
||||
class IntegerAtom implements AtomInterface
|
||||
{
|
||||
protected $value;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
if ($this->isInvalidOrFloat($value)) {
|
||||
throw new AtomException(get_class($this), $value);
|
||||
}
|
||||
|
||||
$this->value = (int)$value;
|
||||
}
|
||||
|
||||
protected function isInvalidOrFloat($value)
|
||||
{
|
||||
return is_numeric($value) === false || is_float($value) === true;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user