1: <?php
2:
3: /**
4: * Copyright 2015, Eduardo Trujillo
5: *
6: * For the full copyright and license information, please view the LICENSE
7: * file that was distributed with this source code.
8: *
9: * This file is part of the Nucleus package
10: */
11:
12: namespace Chromabits\Nucleus\Meditation\Constraints;
13:
14: use Chromabits\Nucleus\Foundation\BaseObject;
15:
16: /**
17: * Class AbstractConstraint.
18: *
19: * @author Eduardo Trujillo <ed@chromabits.com>
20: * @package Chromabits\Nucleus\Meditation\Constraints
21: */
22: abstract class AbstractConstraint extends BaseObject
23: {
24: /**
25: * Check if the constraint is met.
26: *
27: * @param mixed $value
28: * @param array $context
29: *
30: * @return mixed
31: */
32: abstract public function check($value, array $context = []);
33:
34: /**
35: * Get string representation of this constraint.
36: *
37: * @return mixed
38: */
39: abstract public function toString();
40:
41: /**
42: * Get string representation of this constraint.
43: *
44: * @return mixed
45: */
46: public function __toString()
47: {
48: return $this->toString();
49: }
50:
51: /**
52: * Get the description of the constraint.
53: *
54: * @return string
55: */
56: public function getDescription()
57: {
58: return 'The value is expected to meet the constraint.';
59: }
60: }
61: