1: <?php
2: /**
3: * PHP version 5
4: * @package generalDriver
5: * @author Christian Schiffler <c.schiffler@cyberspectrum.de>
6: * @author Stefan Heimes <stefan_heimes@hotmail.com>
7: * @author Tristan Lins <tristan.lins@bit3.de>
8: * @copyright The MetaModels team.
9: * @license LGPL.
10: * @filesource
11: */
12:
13: namespace DcGeneral\DataDefinition\Palette\Condition\Property;
14:
15: use DcGeneral\Data\ModelInterface;
16: use DcGeneral\Data\PropertyValueBag;
17:
18: /**
19: * Negate a condition.
20: */
21: class NotCondition implements PropertyConditionInterface
22: {
23: /**
24: * The condition to negate.
25: *
26: * @var PropertyConditionInterface
27: */
28: protected $condition;
29:
30: /**
31: * Create a new instance.
32: *
33: * @param PropertyConditionInterface $condition The condition to negate.
34: */
35: public function __construct(PropertyConditionInterface $condition)
36: {
37: $this->condition = $condition;
38: }
39:
40: /**
41: * Set the condition to negate.
42: *
43: * @param PropertyConditionInterface $condition The condition.
44: *
45: * @return NotCondition
46: */
47: public function setCondition(PropertyConditionInterface $condition)
48: {
49: $this->condition = $condition;
50: return $this;
51: }
52:
53: /**
54: * Retrieve the condition to negate.
55: *
56: * @return PropertyConditionInterface
57: */
58: public function getCondition()
59: {
60: return $this->condition;
61: }
62:
63: /**
64: * {@inheritdoc}
65: */
66: public function match(ModelInterface $model = null, PropertyValueBag $input = null)
67: {
68: return !$this->condition->match($model, $input);
69: }
70:
71: /**
72: * {@inheritdoc}
73: */
74: public function __clone()
75: {
76: $this->condition = clone $this->condition;
77: }
78: }
79: