1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: namespace DcGeneral\DataDefinition\Palette\Condition\Property;
14:
15: use DcGeneral\Data\ModelInterface;
16: use DcGeneral\Data\PropertyValueBag;
17: use DcGeneral\DataDefinition\AbstractConditionChain;
18: use DcGeneral\Exception\DcGeneralRuntimeException;
19:
20: 21: 22:
23: class PropertyConditionChain extends AbstractConditionChain implements PropertyConditionInterface
24: {
25: 26: 27: 28: 29: 30:
31: public function match(ModelInterface $model = null, PropertyValueBag $input = null)
32: {
33: if ($this->conjunction == static::AND_CONJUNCTION)
34: {
35: foreach ($this->conditions as $condition)
36: {
37: if (!($condition instanceof PropertyConditionInterface))
38: {
39: throw new DcGeneralRuntimeException('Invalid condition in chain: '. get_class($condition));
40: }
41:
42: if (!$condition->match($model, $input))
43: {
44: return false;
45: }
46: }
47:
48: return true;
49: }
50:
51: foreach ($this->conditions as $condition)
52: {
53: if (!($condition instanceof PropertyConditionInterface))
54: {
55: throw new DcGeneralRuntimeException('Invalid condition in chain: '. get_class($condition));
56: }
57:
58: if ($condition->match($model, $input))
59: {
60: return true;
61: }
62: }
63:
64: return false;
65: }
66: }
67: