| 1 | <?php |
||
| 9 | abstract class AbstractCondition implements ConditionInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var string |
||
| 13 | */ |
||
| 14 | private $code; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var TargetDefinitionInterface |
||
| 18 | */ |
||
| 19 | protected $target; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * AbstractCondition constructor. |
||
| 23 | * |
||
| 24 | * @param string $code |
||
| 25 | * @param TargetDefinitionInterface $target |
||
| 26 | */ |
||
| 27 | 2 | public function __construct($code, TargetDefinitionInterface $target) |
|
| 32 | |||
| 33 | /** {@inheritdoc} */ |
||
| 34 | public function attach(TargetDefinitionInterface $target, $code) |
||
| 40 | |||
| 41 | /** {@inheritdoc} */ |
||
| 42 | 3 | public function match($object) |
|
| 50 | |||
| 51 | /** |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | public function getCode() |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @return TargetDefinitionInterface |
||
| 61 | */ |
||
| 62 | public function getTarget() |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Checks whether the object is valid argument to perform matching |
||
| 69 | * |
||
| 70 | * @param mixed $object |
||
| 71 | * |
||
| 72 | * @return bool |
||
| 73 | */ |
||
| 74 | abstract protected function supports($object); |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Verify that object matches according to condition configuration |
||
| 78 | * |
||
| 79 | * @param $object |
||
| 80 | * |
||
| 81 | * @return int|null |
||
| 82 | */ |
||
| 83 | abstract protected function doMatch($object); |
||
| 84 | } |
||
| 85 |