Conditions | 1 |
Paths | 1 |
Total Lines | 90 |
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 |
||
94 | public static function getYamlTimerConfigFile() |
||
95 | { |
||
96 | $today = new \DateTime(); |
||
97 | $tomorrow = new \DateTime('tomorrow'); |
||
98 | |||
99 | return <<<EOT |
||
100 | --- |
||
101 | timers: |
||
102 | example_timer_config_1: |
||
103 | interval: |
||
104 | - [ "2013-02-06" ] # 00:00:00 - 23:59:59 |
||
105 | - [ "{$today->format('Y-m-d H:i:s')}", "{$tomorrow->format('Y-m-d H:i:s')}" ] |
||
106 | |||
107 | example_timer_config_2: |
||
108 | interval: |
||
109 | - [ "2013-02-28" ] # only works for this day, 00:00:00 - 23:59:59 |
||
110 | - [ "2013-04-24" ] |
||
111 | |||
112 | example_timer_config_3: |
||
113 | day: [ monday, tuesday, wednesday, thursday ] # works weekdays 00:00:00 - 23:59:59 |
||
114 | |||
115 | example_timer_config_3.1: |
||
116 | day: [ monday, tuesday, wednesday, thursday, friday, saturday, sunday ] |
||
117 | |||
118 | example_timer_config_4: |
||
119 | day: [ monday ] # works only mondays |
||
120 | time: |
||
121 | - [ "01:05:00", "17:00:00" ] # from 01:05:00 to 17:00:00 |
||
122 | |||
123 | example_timer_config_4.1: |
||
124 | day: [ monday, tuesday, wednesday, thursday, friday, saturday, sunday ] |
||
125 | time: |
||
126 | - [ "01:05:00", "17:00:00" ] # from 01:05:00 to 17:00:00 |
||
127 | |||
128 | example_timer_config_5: |
||
129 | time: |
||
130 | - [ "01:05:00", "17:00:00" ] # from 01:05:00 to 17:00:00 |
||
131 | |||
132 | example_timer_config_6: |
||
133 | holiday: |
||
134 | use_gerneral: true # if false, uses separate holidays conf |
||
135 | additional: [ sub, 1 ] # add or subract n days to holiday to create range |
||
136 | |||
137 | example_timer_config_7: |
||
138 | holiday: |
||
139 | use_gerneral: true # if false, uses separate holidays conf |
||
140 | additional: [ sub, 1 ] # add or subract n days to holiday to create range |
||
141 | interval: [ "16:00:00", "16:00:00" ] # start and end time |
||
142 | |||
143 | example_timer_config_7.1: |
||
144 | holiday: |
||
145 | use_gerneral: true |
||
146 | additional: [ add, 1 ] |
||
147 | interval: [ "16:00:00", "16:00:00" ] # start and end time |
||
148 | |||
149 | general_shipping_promise: |
||
150 | holiday: |
||
151 | use_general: true |
||
152 | additional: [ sub, 1 ] # add or subract n days to holiday to create range |
||
153 | interval: [ "16:00:00", "16:00:00" ] # start and end time |
||
154 | day: [ monday, tuesday, wednesday, thursday, friday, sunday ] |
||
155 | |||
156 | shipping_promise_sunday: |
||
157 | day: [ sunday ] # works only sundays |
||
158 | time: |
||
159 | - [ "00:00:01", "16:00:00" ] # from 00:00:01 to 16:00:00 |
||
160 | |||
161 | |||
162 | |||
163 | holidays: |
||
164 | - [ "2014-10-29" ] # can be intervals or single dates/DateTime touples |
||
165 | |||
166 | general_holidays: # german (baden-wuerttemberg) holidays |
||
167 | - { name: "Neujahr", value: [ "01", "01" ], type: fix } |
||
168 | - { name: "heilige drei Koenige", value: [ "01", "06" ], type: fix } |
||
169 | - { name: "Karfreitag", value: [ sub, 2 ], type: var } |
||
170 | - { name: "Ostermontag", value: [ add, 1 ], type: var } |
||
171 | - { name: "Tag der Arbeit", value: [ "05", "01" ], type: fix } |
||
172 | - { name: "Christi Himmelfahrt", value: [ add, 39], type: var } |
||
173 | - { name: "Pfingstmontag", value: [ add, 50], type: var } |
||
174 | - { name: "Fronleichnam", value: [ add, 60], type: var } |
||
175 | - { name: "Tag der deutschen Einheit", value: [ "10", "03" ], type: fix } |
||
176 | - { name: "allerheiligen", value: [ "11", "01" ], type: fix } |
||
177 | - { name: "Heiligabend", value: [ "12", "24" ], type: fix } |
||
178 | - { name: "erster Weihnachtstag", value: [ "12", "25" ], type: fix } |
||
179 | - { name: "zweiter Weihnachtstag", value: [ "12", "26" ], type: fix } |
||
180 | - { name: "Silvester", value: [ "12", "31" ], type: fix } |
||
181 | EOT; |
||
182 | |||
183 | } |
||
184 | } |
||
185 |