Completed
Push — master ( adf315...23c3de )
by Cheren
02:19
created

CodeStyle   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 73
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testCyrillic() 0 25 3
1
<?php
2
/**
3
 * CakeCMS Core
4
 *
5
 * This file is part of the of the simple cms based on CakePHP 3.
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @package   Core
10
 * @license   MIT
11
 * @copyright MIT License http://www.opensource.org/licenses/mit-license.php
12
 * @link      https://github.com/CakeCMS/Core".
13
 * @author    Sergey Kalistratov <[email protected]>
14
 */
15
16
namespace Core\TestSuite;
17
18
use JBZoo\PHPUnit\Codestyle as JBCodeStyle;
19
use JBZoo\Utils\Arr;
20
use Symfony\Component\Finder\Finder;
21
use Symfony\Component\Finder\SplFileInfo;
22
23
/**
24
 * Class CodeStyle
25
 *
26
 * @package Core\TestSuite
27
 */
28
class CodeStyle extends JBCodeStyle
29
{
30
31
    /**
32
     * Package name.
33
     *
34
     * @var string
35
     */
36
    protected $_packageName = ''; // Overload me!
37
38
    /**
39
     * Package vendor.
40
     *
41
     * @var string
42
     */
43
    protected $_packageVendor = 'CakeCMS';
44
45
    /**
46
     * Package link.
47
     *
48
     * @var string
49
     */
50
    protected $_packageLink = 'https://github.com/CakeCMS/_PACKAGE_';
51
52
    /**
53
     * Package copyright.
54
     *
55
     * @var string
56
     */
57
    protected $_packageCopyright = 'MIT License http://www.opensource.org/licenses/mit-license.php';
58
59
    /**
60
     * Package description.
61
     *
62
     * @var array
63
     */
64
    protected $_packageDesc = [
65
        'This file is part of the of the simple cms based on CakePHP 3.',
66
        'For the full copyright and license information, please view the LICENSE',
67
        'file that was distributed with this source code.'
68
    ];
69
70
    /**
71
     * Try to find cyrilic symbols in the code.
72
     *
73
     * @return void
74
     */
75
    public function testCyrillic()
76
    {
77
        $finder = new Finder();
78
        $finder
79
            ->files()
80
            ->in(PROJECT_ROOT)
81
            ->exclude($this->_excludePaths)
82
            ->exclude('tests')
83
            ->notPath(basename(__FILE__))
84
            ->notName('/\.md$/')
85
            ->notName('/empty/')
86
            ->notName('/\.min\.(js|css)$/')
87
            ->notName('/\.min\.(js|css)\.map$/');
88
89
        /** @var \SplFileInfo $file */
90
        foreach ($finder as $file) {
91
            $content = \JBZoo\PHPUnit\openFile($file->getPathname());
92
93
            if (preg_match('#[А-Яа-яЁё]#ius', $content)) {
94
                \JBZoo\PHPUnit\fail('File contains cyrilic symbols: ' . $file); // Short message in terminal
95
            } else {
96
                \JBZoo\PHPUnit\success();
97
            }
98
        }
99
    }
100
}
101