- var_dump: documentation ( source)
- in_array: documentation ( source)
<?php
class A {
const STATUS_ACTIVE = 'active';
const STATUS_BLOCKED = 'blocked';
private static $props = [
self::STATUS_ACTIVE,
self::STATUS_BLOCKED,
];
public function setProp($prop) {
if (!in_array($prop, self::$props)) {
throw new InvalidArgumentException();
}
$this->prop = $prop;
}
}
$a = new A();
$a->setProp(0);
var_dump($a);