1 | <?php |
||
22 | class GherkinFileLoader extends AbstractFileLoader |
||
23 | { |
||
24 | protected $parser; |
||
25 | protected $cache; |
||
26 | |||
27 | /** |
||
28 | * Initializes loader. |
||
29 | * |
||
30 | * @param Parser $parser Parser |
||
31 | * @param CacheInterface $cache Cache layer |
||
32 | */ |
||
33 | 5 | public function __construct(Parser $parser, CacheInterface $cache = null) |
|
34 | { |
||
35 | 5 | $this->parser = $parser; |
|
36 | 5 | $this->cache = $cache; |
|
37 | 5 | } |
|
38 | |||
39 | /** |
||
40 | * Sets cache layer. |
||
41 | * |
||
42 | * @param CacheInterface $cache Cache layer |
||
43 | */ |
||
44 | 2 | public function setCache(CacheInterface $cache) |
|
45 | { |
||
46 | 2 | $this->cache = $cache; |
|
47 | 2 | } |
|
48 | |||
49 | /** |
||
50 | * Checks if current loader supports provided resource. |
||
51 | * |
||
52 | * @param mixed $path Resource to load |
||
53 | * |
||
54 | * @return Boolean |
||
55 | */ |
||
56 | 2 | public function supports($path) |
|
62 | |||
63 | /** |
||
64 | * Loads features from provided resource. |
||
65 | * |
||
66 | * @param string $path Resource to load |
||
67 | * |
||
68 | * @return FeatureNode[] |
||
69 | */ |
||
70 | 4 | public function load($path) |
|
86 | |||
87 | /** |
||
88 | * Parses feature at provided absolute path. |
||
89 | * |
||
90 | * @param string $path Feature path |
||
91 | * |
||
92 | * @return FeatureNode |
||
93 | */ |
||
94 | 3 | protected function parseFeature($path) |
|
102 | } |
||
103 |
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
.