Conditions | 3 |
Paths | 1 |
Total Lines | 121 |
Code Lines | 55 |
Lines | 0 |
Ratio | 0 % |
Tests | 55 |
CRAP Score | 3 |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
57 | 1 | public function __construct(array $options = array()) |
|
58 | { |
||
59 | // The specified formatting options are merged with the default values. |
||
60 | 1 | $this->options = array_merge( |
|
61 | array( |
||
62 | |||
63 | /** |
||
64 | * The format of the result. |
||
65 | * |
||
66 | * @var string The type ('text', 'cli' or 'html') |
||
67 | */ |
||
68 | 1 | 'type' => php_sapi_name() == 'cli' ? 'cli' : 'text', |
|
69 | |||
70 | /** |
||
71 | * The line ending used. |
||
72 | * By default, for text this is "\n" and for HTML this is "<br/>". |
||
73 | * |
||
74 | * @var string |
||
75 | */ |
||
76 | 1 | 'line_ending' => $this->options['type'] == 'html' ? '<br/>' : "\n", |
|
77 | |||
78 | /** |
||
79 | * The string used for indentation. |
||
80 | * |
||
81 | * @var string |
||
82 | */ |
||
83 | 1 | 'indentation' => " ", |
|
1 ignored issue
–
show
|
|||
84 | |||
85 | /** |
||
86 | * Whether comments should be removed or not. |
||
87 | * |
||
88 | * @var bool |
||
89 | */ |
||
90 | 1 | 'remove_comments' => false, |
|
91 | |||
92 | /** |
||
93 | * Whether each clause should be on a new line. |
||
94 | * |
||
95 | * @var bool |
||
96 | */ |
||
97 | 1 | 'clause_newline' => true, |
|
98 | |||
99 | /** |
||
100 | * Whether each part should be on a new line. |
||
101 | * Parts are delimited by brackets and commas. |
||
102 | * |
||
103 | * @var bool |
||
104 | */ |
||
105 | 1 | 'parts_newline' => true, |
|
106 | |||
107 | /** |
||
108 | * Whether each part of each clause should be indented. |
||
109 | * |
||
110 | * @var bool |
||
111 | */ |
||
112 | 1 | 'indent_parts' => true, |
|
113 | |||
114 | /** |
||
115 | * The styles used for HTML formatting. |
||
116 | * array($type, $flags, $span, $callback) |
||
117 | * |
||
118 | * @var array[] |
||
119 | */ |
||
120 | 'formats' => array( |
||
121 | array( |
||
122 | 1 | 'type' => Token::TYPE_KEYWORD, |
|
123 | 1 | 'flags' => Token::FLAG_KEYWORD_RESERVED, |
|
124 | 1 | 'html' => 'class="sql-reserved"', |
|
125 | 1 | 'cli' => "\e[35m", |
|
126 | 1 | 'function' => 'strtoupper', |
|
127 | 1 | ), |
|
128 | array( |
||
129 | 1 | 'type' => Token::TYPE_KEYWORD, |
|
130 | 1 | 'flags' => 0, |
|
131 | 1 | 'html' => 'class="sql-keyword"', |
|
132 | 1 | 'cli' => "\e[95m", |
|
133 | 1 | 'function' => 'strtoupper', |
|
134 | 1 | ), |
|
135 | array( |
||
136 | 1 | 'type' => Token::TYPE_COMMENT, |
|
137 | 1 | 'flags' => 0, |
|
138 | 1 | 'html' => 'class="sql-comment"', |
|
139 | 1 | 'cli' => "\e[37m", |
|
1 ignored issue
–
show
|
|||
140 | 1 | 'function' => '', |
|
141 | 1 | ), |
|
142 | array( |
||
143 | 1 | 'type' => Token::TYPE_BOOL, |
|
144 | 1 | 'flags' => 0, |
|
145 | 1 | 'html' => 'class="sql-atom"', |
|
146 | 1 | 'cli' => "\e[36m", |
|
1 ignored issue
–
show
|
|||
147 | 1 | 'function' => 'strtoupper', |
|
148 | 1 | ), |
|
149 | array( |
||
150 | 1 | 'type' => Token::TYPE_NUMBER, |
|
151 | 1 | 'flags' => 0, |
|
152 | 1 | 'html' => 'class="sql-number"', |
|
153 | 1 | 'cli' => "\e[92m", |
|
1 ignored issue
–
show
|
|||
154 | 1 | 'function' => 'strtolower', |
|
155 | 1 | ), |
|
156 | array( |
||
157 | 1 | 'type' => Token::TYPE_STRING, |
|
158 | 1 | 'flags' => 0, |
|
159 | 1 | 'html' => 'class="sql-string"', |
|
160 | 1 | 'cli' => "\e[91m", |
|
1 ignored issue
–
show
|
|||
161 | 1 | 'function' => '', |
|
162 | 1 | ), |
|
163 | array( |
||
164 | 1 | 'type' => Token::TYPE_SYMBOL, |
|
165 | 1 | 'flags' => 0, |
|
166 | 1 | 'html' => 'class="sql-variable"', |
|
167 | 1 | 'cli' => "\e[36m", |
|
1 ignored issue
–
show
|
|||
168 | 1 | 'function' => '', |
|
169 | 1 | ), |
|
170 | ) |
||
171 | 1 | ), |
|
172 | $options |
||
173 | 1 | ); |
|
174 | |||
175 | // `parts_newline` requires `clause_newline` |
||
1 ignored issue
–
show
|
|||
176 | 1 | $this->options['parts_newline'] &= $this->options['clause_newline']; |
|
177 | 1 | } |
|
178 | |||
533 |
This check marks property names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString
.