PhpCsFixer   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 33
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfiguration() 0 4 1
A setVersion() 0 4 1
A getVersion() 0 8 2
A determineVersion() 0 9 2
1
<?php
2
/**
3
 * PHP-CS-Fixer plugin for HiDev
4
 *
5
 * @link      https://github.com/hiqdev/hidev-php-cs-fixer
6
 * @package   hidev-php-cs-fixer
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hidev\phpcsfixer\components;
12
13
/**
14
 * php-cs-fixer.
15
 */
16
class PhpCsFixer extends \hidev\base\Component
17
{
18
    protected $_version;
19
20
    public function getConfiguration()
21
    {
22
        return $this->take('.php_cs');
23
    }
24
25
    public function setVersion($value)
26
    {
27
        $this->_version = $value;
28
    }
29
30
    public function getVersion()
31
    {
32
        if ($this->_version === null) {
33
            $this->_version = $this->determineVersion();
34
        }
35
36
        return $this->_version;
37
    }
38
39
    public function determineVersion()
40
    {
41
        $str = reset($this->exec('php-cs-fixer', ['--version']));
0 ignored issues
show
Bug introduced by Andrii Vasyliev
$this->exec('php-cs-fixer', array('--version')) cannot be passed to reset() as the parameter $array expects a reference.
Loading history...
42
        if (preg_match('/PHP CS Fixer (\S+) /', $str, $matches)) {
43
            return $matches[1];
44
        }
45
46
        return '1.x';
47
    }
48
}
49