| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | public function make( $type ) { |
||
| 27 | $condition_type_superclass = 'Carbon_Fields\\Container\\Condition\\Condition'; |
||
| 28 | $normalized_type = Helper::normalize_type( $type ); |
||
| 29 | |||
| 30 | $identifier = 'container_condition_type_' . $normalized_type; |
||
| 31 | if ( \Carbon_Fields\Carbon_Fields::has( $identifier ) ) { |
||
| 32 | return \Carbon_Fields\Carbon_Fields::resolve( $identifier ); |
||
| 33 | } |
||
| 34 | |||
| 35 | if ( class_exists( $type ) ) { |
||
| 36 | $reflection = new \ReflectionClass( $type ); |
||
| 37 | if ( $reflection->isSubclassOf( $condition_type_superclass ) ) { |
||
| 38 | return new $type(); |
||
| 39 | } else { |
||
| 40 | Incorrect_Syntax_Exception::raise( 'Condition must be of type ' . $condition_type_superclass ); |
||
| 41 | return null; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | Incorrect_Syntax_Exception::raise( 'Unknown condition type "' . $type . '".' ); |
||
| 46 | return null; |
||
| 47 | } |
||
| 48 | } |