1 | <?php |
||
21 | class YamlFileLoader extends AbstractFileLoader |
||
22 | { |
||
23 | private $loader; |
||
24 | |||
25 | 35 | public function __construct() |
|
29 | |||
30 | /** |
||
31 | * Checks if current loader supports provided resource. |
||
32 | * |
||
33 | * @param mixed $path Resource to load |
||
34 | * |
||
35 | * @return Boolean |
||
36 | */ |
||
37 | 1 | public function supports($path) |
|
38 | { |
||
39 | 1 | return is_string($path) |
|
40 | 1 | && is_file($absolute = $this->findAbsolutePath($path)) |
|
41 | 1 | && 'yml' === pathinfo($absolute, PATHINFO_EXTENSION); |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * Loads features from provided resource. |
||
46 | * |
||
47 | * @param string $path Resource to load |
||
48 | * |
||
49 | * @return FeatureNode[] |
||
50 | */ |
||
51 | 34 | public function load($path) |
|
73 | } |
||
74 |
This check looks for type mismatches where the missing type is
false
. This is usually indicative of an error condtion.Consider the follow example
This function either returns a new
DateTime
object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returnedfalse
before passing on the value to another function or method that may not be able to handle afalse
.