These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | /** |
||
3 | * Created by PhpStorm. |
||
4 | * User: ignatenkov_nv |
||
5 | * Date: 27.08.2015 |
||
6 | * Time: 15:55 |
||
7 | */ |
||
8 | |||
9 | |||
10 | /** |
||
11 | * Load img in yandex css |
||
12 | * Class ParseCss |
||
13 | */ |
||
14 | class ParseCss { |
||
15 | |||
16 | public $dir = "css/"; |
||
17 | public $listCss = ['_index.css']; |
||
18 | public $pattern = "/yastatic.net.*.svg/"; |
||
19 | |||
20 | public $patternFileName = "(yastatic.+\/)([^/]+.\.svg)"; |
||
21 | public $patternFileName1 = "/[^/]+.\.svg/"; |
||
22 | |||
23 | public function parse() { |
||
24 | foreach ($this->listCss as $value) { |
||
25 | //echo $this->getFilePath($value); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
78% of this comment could be valid code. Did you maybe forget this after debugging?
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. ![]() |
|||
26 | $contents = file_get_contents($this->getFilePath($value)); |
||
27 | |||
28 | if(preg_match_all($this->pattern, $contents, $matches)){ |
||
29 | //echo "Found matches:\n"; |
||
30 | //echo implode("\n", $matches[0]); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
77% of this comment could be valid code. Did you maybe forget this after debugging?
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. ![]() |
|||
31 | foreach ($matches[0] as $val) { |
||
32 | |||
33 | //preg_match($this->patternFileName1, $val, $matc); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% of this comment could be valid code. Did you maybe forget this after debugging?
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. ![]() |
|||
34 | //var_dump($matc); |
||
35 | //echo $val; |
||
36 | $fileName = basename($val); |
||
37 | $path = str_replace($fileName, "", $val); |
||
38 | $path = str_replace("yastatic.net/", "", $path); |
||
39 | $path = "img/".$path; |
||
40 | //echo $path . " - " . $fileName."<br>"; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
43% of this comment could be valid code. Did you maybe forget this after debugging?
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. ![]() |
|||
41 | |||
42 | if (!file_exists($path)) |
||
43 | mkdir($path, 0777, true); |
||
44 | |||
45 | $image = file_get_contents("https://".$val); |
||
46 | file_put_contents($path.$fileName, $image); |
||
47 | } |
||
48 | |||
49 | //var_dump($matches); |
||
50 | } |
||
51 | |||
52 | } |
||
53 | |||
54 | return null; |
||
55 | |||
56 | } |
||
57 | |||
58 | private function getFilePath($filename) { |
||
59 | return $this->dir.$filename; |
||
60 | } |
||
61 | |||
62 | |||
63 | } |
||
64 | |||
65 | |||
66 | $parse = new ParseCss(); |
||
67 | $parse->parse(); |
||
68 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.