1 | <?php |
||
16 | class Factory { |
||
17 | /** |
||
18 | * Create a new condition |
||
19 | * |
||
20 | * @param string|array|Closure $options |
||
21 | * @return ConditionInterface |
||
22 | */ |
||
23 | 12 | public static function make( $options ) { |
|
24 | 12 | if ( is_string( $options ) ) { |
|
25 | 2 | return static::makeFromUrl( $options ); |
|
26 | } |
||
27 | |||
28 | 10 | if ( is_array( $options ) ) { |
|
29 | 8 | return static::makeFromArray( $options ); |
|
30 | } |
||
31 | |||
32 | 2 | if ( is_a( $options, Closure::class ) ) { |
|
33 | 1 | return static::makeFromClosure( $options ); |
|
34 | } |
||
35 | |||
36 | 1 | throw new InvalidRouteConditionException( 'Invalid condition options supplied.' ); |
|
37 | } |
||
38 | |||
39 | /** |
||
40 | * Check if the passed argument is a registered condition type |
||
41 | * |
||
42 | * @param mixed $condition_type |
||
43 | * @return boolean |
||
44 | */ |
||
45 | protected static function conditionTypeRegistered( $condition_type ) { |
||
53 | |||
54 | /** |
||
55 | * Resolve the condition type and it's arguments from an options array |
||
56 | * |
||
57 | * @param array $options |
||
58 | * @return array |
||
59 | */ |
||
60 | 6 | protected static function getConditionTypeAndArguments( $options ) { |
|
78 | |||
79 | /** |
||
80 | * Create a new condition from a url |
||
81 | * |
||
82 | * @param string $url |
||
83 | * @return ConditionInterface |
||
84 | */ |
||
85 | 1 | protected static function makeFromUrl( $url ) { |
|
88 | |||
89 | /** |
||
90 | * Create a new condition from an array of conditions |
||
91 | * |
||
92 | * @param array $options |
||
93 | * @return ConditionInterface |
||
94 | */ |
||
95 | 1 | protected static function makeFromArrayOfConditions( $options ) { |
|
98 | |||
99 | /** |
||
100 | * Create a new condition from an array |
||
101 | * |
||
102 | * @param array $options |
||
103 | * @return ConditionInterface |
||
104 | */ |
||
105 | 8 | protected static function makeFromArray( $options ) { |
|
121 | |||
122 | /** |
||
123 | * Create a new condition from a closure |
||
124 | * |
||
125 | * @param Closure $closure |
||
126 | * @return ConditionInterface |
||
127 | */ |
||
128 | 1 | protected static function makeFromClosure( Closure $closure ) { |
|
131 | } |
||
132 |