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\Meditation\Primitives\SpecialTypes;
15:
16: /**
17: * Class MaybeConstraint.
18: *
19: * @author Eduardo Trujillo <ed@chromabits.com>
20: * @package Chromabits\Nucleus\Meditation\Constraints
21: */
22: class MaybeConstraint extends EitherConstraint
23: {
24: /**
25: * Construct an instance of a MaybeConstraint.
26: *
27: * @param AbstractConstraint $other
28: */
29: public function __construct(AbstractConstraint $other)
30: {
31: parent::__construct(
32: $other,
33: new PrimitiveTypeConstraint(SpecialTypes::SPECIAL_NULL)
34: );
35: }
36:
37: /**
38: * Construct an instance of a MaybeConstraint.
39: *
40: * @param AbstractConstraint $other
41: *
42: * @return static
43: */
44: public static function forType(AbstractConstraint $other)
45: {
46: return new static($other);
47: }
48: }
49: