1 | <?php |
||
20 | class CompositionResolver extends BaseObject |
||
21 | { |
||
22 | /** |
||
23 | * @var string The Regular-Expression matching the var finder inside the url parts |
||
24 | */ |
||
25 | const VAR_MATCH_REGEX = '/<(\w+):?([^>]+)?>/'; |
||
26 | |||
27 | /** |
||
28 | * @var Request |
||
29 | */ |
||
30 | protected $request; |
||
31 | |||
32 | /** |
||
33 | * @var string Url matching prefix, which is used for all the modules (e.g. an e-store requireds a language |
||
34 | * as the cms needs this informations too). After proccessing this informations, they will be removed |
||
35 | * from the url for further proccessing. |
||
36 | * |
||
37 | * Examples of how to use patterns: |
||
38 | * |
||
39 | * ```php |
||
40 | * 'pattern' => '<langShortCode:[a-z]{2}>.<countryShortCode:[a-z]{2}>', // de-ch; fr-ch |
||
41 | * ``` |
||
42 | */ |
||
43 | public $pattern; |
||
44 | |||
45 | /** |
||
46 | * @var array Default value if there is no composition provided in the url. The default value must match the url. |
||
47 | */ |
||
48 | public $defaultValues = []; |
||
49 | |||
50 | /** |
||
51 | * Constructor ensures given Request component. |
||
52 | * |
||
53 | * @param Request $request |
||
54 | * @param array $config |
||
55 | */ |
||
56 | public function __construct(Request $request, array $config = []) |
||
61 | |||
62 | /** |
||
63 | * Get the resolved path. |
||
64 | * |
||
65 | * @return string|array |
||
66 | */ |
||
67 | public function getResolvedPath() |
||
71 | |||
72 | /** |
||
73 | * Get resolved composition values as array. |
||
74 | * |
||
75 | * @return array |
||
76 | */ |
||
77 | public function getResolvedValues() |
||
81 | |||
82 | /** |
||
83 | * Get only the resolved composition keys from pattern. |
||
84 | * @return array |
||
85 | */ |
||
86 | public function getResolvedKeys() |
||
90 | |||
91 | /** |
||
92 | * Get a value for a given resolved pattern key. |
||
93 | * |
||
94 | * @param string $key |
||
95 | * @return boolean|mixed |
||
96 | */ |
||
97 | public function getResolvedKeyValue($key) |
||
103 | |||
104 | /** |
||
105 | * Add trailing slash to the request pathinfo. |
||
106 | * |
||
107 | * @return string |
||
108 | */ |
||
109 | protected function trailingPathInfo() |
||
113 | |||
114 | /** |
||
115 | * Generate the regex pattern based on the pattern. |
||
116 | * |
||
117 | * @return string |
||
118 | */ |
||
119 | protected function buildRegexPattern() |
||
123 | |||
124 | private $_resolved; |
||
125 | |||
126 | /** |
||
127 | * Resolve the current data. |
||
128 | * |
||
129 | * @return array |
||
130 | */ |
||
131 | protected function getInternalResolverArray() |
||
189 | } |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.