Conditions | 16 |
Paths | 16 |
Total Lines | 75 |
Code Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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 |
||
38 | public function parseSymbol(FormatToken $token, FormatParserInterface $parser) |
||
39 | { |
||
40 | if ($token->is('o')) { |
||
41 | // o ISO-8601 week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. |
||
42 | return new PregSimple($token, '\d\d\d\d'); |
||
43 | } |
||
44 | |||
45 | if ($token->is('F')) { |
||
46 | // F A full textual representation of a month, such as January or March |
||
47 | return $this->buildXNamesLexer('Month', $token); |
||
48 | } |
||
49 | |||
50 | if ($token->is('M')) { |
||
51 | // M A short textual representation of a month, three letters Jan through Dec |
||
52 | return $this->buildXNamesLexer('MonthShort', $token); |
||
53 | } |
||
54 | |||
55 | if ($token->is('m')) { |
||
56 | // m Numeric representation of a month, with leading zeros 01 through 12 |
||
57 | return new PregSimple($token, '\d\d'); |
||
58 | } |
||
59 | |||
60 | if ($token->is('n')) { |
||
61 | // n Numeric representation of a month, without leading zeros |
||
62 | return new PregSimple($token, '\d\d?'); |
||
63 | } |
||
64 | |||
65 | if ($token->is('t')) { |
||
66 | // t Number of days in the given month |
||
67 | return new PregSimple($token, '\d\d?'); |
||
68 | } |
||
69 | |||
70 | if ($token->is('d')) { |
||
71 | // d Day of the month, 2 digits with leading zeros 01 to 31 |
||
72 | return new PregSimple($token, '\d\d'); |
||
73 | } |
||
74 | |||
75 | if ($token->is('j')) { |
||
76 | // j Day of the month without leading zeros 1 to 31 |
||
77 | return new PregSimple($token, '\d\d?'); |
||
78 | } |
||
79 | |||
80 | if ($token->is('l')) { |
||
81 | // l (lowercase 'L') A full textual representation of the day of the week |
||
82 | return $this->buildXNamesLexer('Day', $token); |
||
83 | } |
||
84 | |||
85 | if ($token->is('D')) { |
||
86 | // D A textual representation of a day, three letters |
||
87 | return $this->buildXNamesLexer('DayShort', $token); |
||
88 | } |
||
89 | |||
90 | if ($token->is('S')) { |
||
91 | // S English ordinal suffix for the day of the month, 2 characters |
||
92 | return $this->buildSuffixesLexer($token); |
||
93 | } |
||
94 | |||
95 | if ($token->is('w')) { |
||
96 | // w Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday) |
||
97 | return new PregSimple($token, '\d'); |
||
98 | } |
||
99 | |||
100 | if ($token->is('z')) { |
||
101 | // z The day of the year (starting from 0) |
||
102 | return new PregSimple($token, '\d{1,3}'); |
||
103 | } |
||
104 | |||
105 | if ($token->is('N')) { |
||
106 | // N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) 1 (for Monday) through 7 (for Sunday) |
||
107 | return new PregSimple($token, '\d'); |
||
108 | } |
||
109 | |||
110 | if ($token->is('W')) { |
||
111 | // W ISO-8601 week number of year, weeks starting on Monday |
||
112 | return new PregSimple($token, '\d\d?'); |
||
113 | } |
||
162 |