1 | <?php |
||
20 | class CdnFacade implements CdnFacadeInterface |
||
21 | { |
||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $configurations; |
||
26 | |||
27 | /** |
||
28 | * @var \Vinelab\Cdn\Contracts\ProviderFactoryInterface |
||
29 | */ |
||
30 | protected $provider_factory; |
||
31 | |||
32 | /** |
||
33 | * instance of the default provider object. |
||
34 | * |
||
35 | * @var \Vinelab\Cdn\Providers\Contracts\ProviderInterface |
||
36 | */ |
||
37 | protected $provider; |
||
38 | |||
39 | /** |
||
40 | * @var \Vinelab\Cdn\Contracts\CdnHelperInterface |
||
41 | */ |
||
42 | protected $helper; |
||
43 | |||
44 | /** |
||
45 | * @var \Vinelab\Cdn\Validators\CdnFacadeValidator |
||
46 | */ |
||
47 | protected $cdn_facade_validator; |
||
48 | |||
49 | /** |
||
50 | * Calls the provider initializer. |
||
51 | * |
||
52 | * @param \Vinelab\Cdn\Contracts\ProviderFactoryInterface $provider_factory |
||
53 | * @param \Vinelab\Cdn\Contracts\CdnHelperInterface $helper |
||
54 | * @param \Vinelab\Cdn\Validators\CdnFacadeValidator $cdn_facade_validator |
||
55 | */ |
||
56 | public function __construct( |
||
57 | ProviderFactoryInterface $provider_factory, |
||
58 | CdnHelperInterface $helper, |
||
59 | CdnFacadeValidator $cdn_facade_validator |
||
60 | ) { |
||
61 | $this->provider_factory = $provider_factory; |
||
62 | $this->helper = $helper; |
||
63 | $this->cdn_facade_validator = $cdn_facade_validator; |
||
64 | |||
65 | $this->init(); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * this function will be called from the 'views' using the |
||
70 | * 'Cdn' facade {{Cdn::asset('')}} to convert the path into |
||
71 | * it's CDN url. |
||
72 | * |
||
73 | * @param $path |
||
74 | * |
||
75 | * @return mixed |
||
76 | * |
||
77 | * @throws Exceptions\EmptyPathException |
||
78 | */ |
||
79 | public function asset($path) |
||
80 | { |
||
81 | return $this->generateUrl($path); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * this function will be called from the 'views' using the |
||
86 | * 'Cdn' facade {{Cdn::elixir('')}} to convert the elixir generated file path into |
||
87 | * it's CDN url. |
||
88 | * |
||
89 | * @param $path |
||
90 | * |
||
91 | * @return mixed |
||
92 | * |
||
93 | * @throws Exceptions\EmptyPathException, \InvalidArgumentException |
||
94 | */ |
||
95 | public function elixir($path) |
||
106 | |||
107 | /** |
||
108 | * this function will be called from the 'views' using the |
||
109 | * 'Cdn' facade {{Cdn::mix('')}} to convert the Laravel 5.4 webpack mix |
||
110 | * generated file path into it's CDN url. |
||
111 | * |
||
112 | * @param $path |
||
113 | * |
||
114 | * @return mixed |
||
115 | * |
||
116 | * @throws Exceptions\EmptyPathException, \InvalidArgumentException |
||
117 | */ |
||
118 | public function mix($path) |
||
146 | |||
147 | /** |
||
148 | * this function will be called from the 'views' using the |
||
149 | * 'Cdn' facade {{Cdn::path('')}} to convert the path into |
||
150 | * it's CDN url. |
||
151 | * |
||
152 | * @param $path |
||
153 | * |
||
154 | * @return mixed |
||
155 | * |
||
156 | * @throws Exceptions\EmptyPathException |
||
157 | */ |
||
158 | public function path($path) |
||
162 | |||
163 | /** |
||
164 | * check if package is surpassed or not then |
||
165 | * prepare the path before generating the url. |
||
166 | * |
||
167 | * @param $path |
||
168 | * |
||
169 | * @return mixed |
||
170 | */ |
||
171 | private function generateUrl($path) |
||
197 | |||
198 | /** |
||
199 | * Read the configuration file and pass it to the provider factory |
||
200 | * to return an object of the default provider specified in the |
||
201 | * config file. |
||
202 | */ |
||
203 | private function init() |
||
211 | } |
||
212 |
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.