13declare(strict_types=1);
15namespace pocketmine\network\mcpe\protocol\types\entity;
17trait IntegerishMetadataProperty{
18 public function __construct(
21 if($value < $this->min() or $value > $this->max()){
22 throw new \InvalidArgumentException(
"Value is out of range " . $this->min() .
" - " . $this->max());
26 abstract protected function min() : int;
28 abstract protected function max() : int;
30 public function getValue() : int{
34 public function equals(MetadataProperty $other) : bool{
35 return $other instanceof self and $other->value === $this->value;
42 public static function buildFromFlags(array $flags) : self{
44 foreach($flags as $flag => $v){
49 return new self($value);