- var_dump: documentation ( source)
- in_array: documentation ( source)
<?php
class A {
const PROP_1 = 'prop';
const PROP_2 = 'more_prop';
private static $props = [
self::PROP_1,
self::PROP_2,
];
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);