Conditions | 4 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 0 |
1 | <?php |
||
27 | public function make( $type ) { |
||
28 | $condition_type_superclass = 'Carbon_Fields\\Container\\Condition\\Condition'; |
||
1 ignored issue
–
show
|
|||
29 | $normalized_type = Helper::normalize_type( $type ); |
||
30 | |||
31 | $identifier = 'container_condition_type_' . $normalized_type; |
||
32 | if ( App::has( $identifier ) ) { |
||
33 | return App::resolve( $identifier ); |
||
34 | } |
||
35 | |||
36 | if ( class_exists( $type ) ) { |
||
37 | $reflection = new \ReflectionClass( $type ); |
||
38 | if ( $reflection->isSubclassOf( $condition_type_superclass ) ) { |
||
39 | return new $type(); |
||
40 | } else { |
||
41 | Incorrect_Syntax_Exception::raise( 'Field must be of type Carbon_Fields\\Field\\Field' ); |
||
42 | } |
||
43 | } |
||
44 | |||
45 | Incorrect_Syntax_Exception::raise( 'Unknown condition type "' . $type . '".' ); |
||
46 | return null; |
||
47 | } |
||
48 | } |
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.