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

CodeStyle::testCyrillic()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
rs 8.8571
cc 3
eloc 18
nc 3
nop 0
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