PrettyPSR   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createIn() 0 5 1
A __construct() 0 6 1
A getDefaultFixers() 0 56 1
1
<?php
2
namespace nochso\Omni\PhpCsFixer;
3
4
use Symfony\CS\Config\Config;
5
use Symfony\CS\FixerInterface;
6
7
/**
8
 * PrettyPSR lies inbetween FixerInterface's PSR2 and Symfony level.
9
 *
10
 * Create a new file `.php_cs` in your project root:
11
 *
12
 * ```
13
 * <?php
14
 * require_once 'vendor/autoload.php';
15
 * use nochso\Omni\PhpCsFixer\PrettyPSR;
16
 * return PrettyPSR::createIn(['src', 'test']);
17
 * ```
18
 *
19
 * Running `php-cs-fixer` will fix all files in folders `src` and `test`.
20
 *
21
 * Note that `php-cs-fixer` is not included by default. You have to require it first:
22
 * ```
23
 * composer require --dev fabpot/php-cs-fixer
24
 * ```
25
 */
26
class PrettyPSR extends Config {
27
	/**
28
	 * @param string|array $dirs
29
	 *
30
	 * @return static
31
	 */
32
	public static function createIn($dirs) {
33
		$config = new static();
34
		$config->finder(DefaultFinder::createIn($dirs));
35
		return $config;
36
	}
37
38
	/**
39
	 * @param string $name
40
	 * @param string $description
41
	 */
42
	public function __construct($name = self::class, $description = '') {
43
		parent::__construct($name, $description);
44
		$this->level = FixerInterface::PSR2_LEVEL;
45
		$this->fixers = $this->getDefaultFixers();
46
		$this->setUsingCache(true);
47
	}
48
49
	/**
50
	 * @return string[]
51
	 */
52
	public function getDefaultFixers() {
53
		return [
54
			'-psr0',
55
			'-return',
56
			'-concat_without_spaces',
57
			'-empty_return',
58
			'extra_empty_lines',
59
			'concat_with_spaces',
60
			'array_element_no_space_before_comma',
61
			'array_element_white_space_after_comma',
62
			'double_arrow_multiline_whitespaces',
63
			'duplicate_semicolon',
64
			'function_typehint_space',
65
			'include',
66
			'list_commas',
67
			'multiline_array_trailing_comma',
68
			'namespace_no_leading_whitespace',
69
			'newline_after_open_tag',
70
			'new_with_braces',
71
			'no_blank_lines_after_class_opening',
72
			'no_blank_lines_before_namespace',
73
			'no_empty_lines_after_phpdocs',
74
			'object_operator',
75
			'operators_spaces',
76
			'spaces_cast',
77
			'ordered_use',
78
			'phpdoc_indent',
79
			'phpdoc_inline_tag',
80
			'phpdoc_no_access',
81
			'phpdoc_no_package',
82
			'phpdoc_order',
83
			'phpdoc_params',
84
			'phpdoc_scalar',
85
			'phpdoc_separation',
86
			'phpdoc_short_description',
87
			'phpdoc_to_comment',
88
			'phpdoc_trim',
89
			'phpdoc_types',
90
			'phpdoc_type_to_var',
91
			'print_to_echo',
92
			'remove_lines_between_uses',
93
			'self_accessor',
94
			'short_array_syntax',
95
			'single_array_no_trailing_comma',
96
			'single_quote',
97
			'spaces_before_semicolon',
98
			'ternary_spaces',
99
			'trim_array_spaces',
100
			'unalign_double_arrow',
101
			'unalign_equals',
102
			'unary_operators_spaces',
103
			'unneeded_control_parentheses',
104
			'unused_use',
105
			'whitespacy_lines',
106
		];
107
	}
108
}
109