1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: namespace DcGeneral\DataDefinition\Palette\Condition\Palette;
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 PaletteConditionChain extends AbstractConditionChain implements PaletteConditionInterface
24: {
25: 26: 27: 28: 29: 30:
31: public function getMatchCount(ModelInterface $model = null, PropertyValueBag $input = null)
32: {
33: $totalCount = false;
34:
35: foreach ($this->conditions as $condition)
36: {
37: if (!($condition instanceof PaletteConditionInterface))
38: {
39: throw new DcGeneralRuntimeException('Invalid condition in chain: '. get_class($condition));
40: }
41:
42: $conditionCount = $condition->getMatchCount($model, $input);
43:
44: if ($conditionCount !== false)
45: {
46: $totalCount += $conditionCount;
47: }
48: elseif ($this->conjunction == static::AND_CONJUNCTION)
49: {
50: return false;
51: }
52: }
53:
54: return $totalCount;
55: }
56: }
57: