Code Duplication    Length = 21-25 lines in 3 locations

src/CalendarSettings/Gregorian.php 1 location

@@ 126-148 (lines=23) @@
123
                                   12 => 30 ),
124
125
126
    'day_of_year' => function ( $date_time ) {
127
128
        $result = null;
129
130
        $_month = null;
131
132
        $config = include 'Gregorian.php';
133
134
        $month = $date_time->format('n');
135
136
        $day = $date_time->format('d');
137
138
        foreach( $config['month_days_number'] as $_month => $value ) {
139
140
            if ($_month < $month ) { $result += $value; 
141
            }
142
143
        }
144
145
        $result += $day;
146
147
        return $result;
148
149
    },
150
151
    'day_of_week' => function ( $date_time ) {

src/CalendarSettings/Hijri.php 1 location

@@ 256-280 (lines=25) @@
253
    *
254
    *\_________________________________________________________/
255
    */
256
     'day_of_year' => function ( $date_time ) {
257
258
        $result = null;
259
260
        $config = include 'Hijri.php';
261
262
        $month = $date_time->format('n');
263
264
        $day = $date_time->format('d');
265
266
        foreach( $config['month_days_number'] as $_month => $value ) {
267
268
            if ($_month < $month ) {
269
270
                $result += $value;
271
272
            }
273
274
        }
275
276
        $result += $day;
277
278
        return $result;
279
280
     },
281
282
     /************************************************************
283
      *                      Day of week

src/CalendarSettings/Jalali.php 1 location

@@ 307-327 (lines=21) @@
304
  *
305
  *\_________________________________________________________/
306
  */
307
  'day_of_year' => function ( $date_time ) {
308
309
    $result = null;
310
311
    $config = include 'Jalali.php';
312
313
    $month = $date_time->format('n');
314
315
    $day = $date_time->format('d');
316
317
    foreach( $config[ 'month_days_number' ] as $_month => $value ) {
318
319
        if ($_month < $month ) { $result += $value; 
320
        }
321
322
    }
323
324
    $result += $day;
325
326
    return $result;
327
328
  },
329
330
  /************************************************************