Completed
Push — master ( 3848cb...1f8425 )
by mehdi
02:54
created
src/CalendarSettings/Jalali.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use OpenCafe\Datium as Datium;
4 4
 use OpenCafe\Tools\Leap as Leap;
5 5
 
6
-return array (
6
+return array(
7 7
 
8 8
   'timezone' => 'Asia/Tehran',
9 9
 
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 
12 12
   'events' => array(),
13 13
 
14
-  'numbers' => array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'),
14
+  'numbers' => array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'),
15 15
 
16 16
   'am_time' => 'AM',
17 17
 
18 18
   'pm_time' => 'PM',
19 19
 
20
-  'end_of_days' => array( 'th', 'st', 'nd', 'rd' ),
20
+  'end_of_days' => array('th', 'st', 'nd', 'rd'),
21 21
 
22 22
 
23 23
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  *
30 30
  *\_________________________________________________________/
31 31
  */
32
-  'convert_to' => function ($date_time) {
32
+  'convert_to' => function($date_time) {
33 33
 
34 34
         $config = include 'Gregorian.php';
35 35
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         $temp_day = 0;
43 43
 
44 44
     for ($i = 1; $i < $month; $i++) {
45
-        $temp_day += $config[ 'month_days_number' ][ $i ];
45
+        $temp_day += $config['month_days_number'][$i];
46 46
     }
47 47
 
48 48
          $temp_day += $day;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     }
55 55
 
56 56
     if ($temp_day <= 79) {
57
-        if (( $year - 1 ) % 4 == 0) {
57
+        if (($year - 1) % 4 == 0) {
58 58
             $temp_day = $temp_day + 11;
59 59
         } else {
60 60
             $temp_day = $temp_day + 10;
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
         $year = $year - 622;
64 64
 
65 65
         if ($temp_day % 30 == 0) {
66
-            $month = ( $temp_day / 30 ) + 9;
66
+            $month = ($temp_day / 30) + 9;
67 67
 
68 68
             $day = 30;
69 69
         } else {
70
-            $month = ( $temp_day / 30 ) + 10;
70
+            $month = ($temp_day / 30) + 10;
71 71
 
72 72
             $day = $temp_day % 30;
73 73
         }
@@ -78,23 +78,23 @@  discard block
 block discarded – undo
78 78
 
79 79
         if ($temp_day <= 186) {
80 80
             if ($temp_day % 31 == 0) {
81
-                $month = ( $temp_day / 31 );
81
+                $month = ($temp_day / 31);
82 82
 
83 83
                 $day = 31;
84 84
             } else {
85
-                $month = ( $temp_day / 31 ) + 1;
85
+                $month = ($temp_day / 31) + 1;
86 86
 
87
-                $day = ( $temp_day % 31 );
87
+                $day = ($temp_day % 31);
88 88
             }
89 89
         } else {
90 90
             $temp_day = $temp_day - 186;
91 91
 
92 92
             if ($temp_day % 30 == 0) {
93
-                $month = ( $temp_day / 30 ) + 6;
93
+                $month = ($temp_day / 30) + 6;
94 94
 
95 95
                 $day = 30;
96 96
             } else {
97
-                $month = ( $temp_day / 30 ) + 7;
97
+                $month = ($temp_day / 30) + 7;
98 98
 
99 99
                 $day = $temp_day % 30;
100 100
             }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
    *
116 116
    *\_________________________________________________________/
117 117
    */
118
-  'convert_from' => function ($date_time) {
118
+  'convert_from' => function($date_time) {
119 119
 
120 120
     $config = include 'Jalali.php';
121 121
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
     $days_of_year = 0;
129 129
 
130
-    foreach ($config[ 'month_days_number' ] as $mon => $value) {
130
+    foreach ($config['month_days_number'] as $mon => $value) {
131 131
         if ($month > $mon) {
132 132
             $days_of_year += $value;
133 133
         }
@@ -135,25 +135,25 @@  discard block
 block discarded – undo
135 135
 
136 136
     $days_of_year += $day;
137 137
 
138
-    $days_of_leap_years =  intval(( ( $year - 1 ) / 4 ));
138
+    $days_of_leap_years = intval((($year - 1) / 4));
139 139
 
140
-    $days_of_shamsi_years = ( ( ( $year - 1 ) * 365 ) + $days_of_year + $days_of_leap_years );
140
+    $days_of_shamsi_years = ((($year - 1) * 365) + $days_of_year + $days_of_leap_years);
141 141
 
142 142
     $days_of_gregorain_years = $days_of_shamsi_years + 226899;
143 143
 
144 144
     if ($month < 10) {
145
-        $days_of_gregorain_years = $days_of_gregorain_years - intval(( ( $year + 621 ) / 4 ));
146
-    } elseif (( ( 10 == $month ) && ( $day > 10 ) ) || ( $month > 10 )) {
147
-        $days_of_gregorain_years = $days_of_gregorain_years - intval(( ( $year + 622 ) / 4 ));
145
+        $days_of_gregorain_years = $days_of_gregorain_years - intval((($year + 621) / 4));
146
+    } elseif (((10 == $month) && ($day > 10)) || ($month > 10)) {
147
+        $days_of_gregorain_years = $days_of_gregorain_years - intval((($year + 622) / 4));
148 148
     }
149 149
 
150
-    $gregorian_month = ( $days_of_gregorain_years % 365 );
150
+    $gregorian_month = ($days_of_gregorain_years % 365);
151 151
 
152 152
     $gregorian_year = intval($days_of_gregorain_years / 365) + 1;
153 153
 
154 154
     $config = include 'Gregorian.php';
155 155
 
156
-    foreach ($config[ 'month_days_number' ] as $month => $value) {
156
+    foreach ($config['month_days_number'] as $month => $value) {
157 157
         if ($gregorian_month < $value) {
158 158
             break;
159 159
         }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
    *
191 191
    *\_________________________________________________________/
192 192
    */
193
-  'month' => array (
193
+  'month' => array(
194 194
 
195 195
     'Farvardin',
196 196
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
    */
230 230
 
231 231
 
232
-  'days_of_week' => array (
232
+  'days_of_week' => array(
233 233
 
234 234
      'Yekshanbe',
235 235
      'Doshanbe',
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
   'start_day_of_week' => 'Shanbe',
245 245
 
246
-  'month_days_number' => array(      1 => 31,
246
+  'month_days_number' => array(1 => 31,
247 247
                                      2 => 31,
248 248
                                      3 => 31,
249 249
                                      4 => 31,
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
                                      9 => 30,
255 255
                                      10 => 30,
256 256
                                      11 => 30,
257
-                                     12 => 29 ),
257
+                                     12 => 29),
258 258
 
259 259
   /************************************************************
260 260
   *                      Day of year
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
   *
265 265
   *\_________________________________________________________/
266 266
   */
267
-  'day_of_year' => function ($date_time) {
267
+  'day_of_year' => function($date_time) {
268 268
 
269 269
     $result = null;
270 270
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 
275 275
     $day = $date_time->format('d');
276 276
 
277
-    foreach ($config[ 'month_days_number' ] as $_month => $value) {
277
+    foreach ($config['month_days_number'] as $_month => $value) {
278 278
         if ($_month < $month) {
279 279
             $result += $value;
280 280
         }
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
    *  example : Yekshanbe = result is 2
295 295
    *\_________________________________________________________/
296 296
   */
297
-  'day_of_week' => function ($date_time) {
297
+  'day_of_week' => function($date_time) {
298 298
 
299
-        $days = array( 1 => 'Shanbe',  2 => 'Yekshanbe', 3 => 'Doshanbe', 4 => 'Seshanbe', 5 => 'Chaharshanbe', 6 => 'Panjshanbe', 7 => 'Jome' );
299
+        $days = array(1 => 'Shanbe', 2 => 'Yekshanbe', 3 => 'Doshanbe', 4 => 'Seshanbe', 5 => 'Chaharshanbe', 6 => 'Panjshanbe', 7 => 'Jome');
300 300
 
301 301
         $configShamsi = include 'Jalali.php';
302 302
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 
305 305
         $day = $date_time->format('l');
306 306
 
307
-        $day = str_replace($configGregorian[ 'days_of_week' ], $configShamsi[ 'days_of_week' ], $day);
307
+        $day = str_replace($configGregorian['days_of_week'], $configShamsi['days_of_week'], $day);
308 308
 
309 309
     foreach ($days as $key => $value) {
310 310
         if ($day == $value) {
@@ -322,24 +322,24 @@  discard block
 block discarded – undo
322 322
    *
323 323
    *\_________________________________________________________/
324 324
    */
325
-  'leap_year' => function ( $year ) {
325
+  'leap_year' => function($year) {
326 326
 
327 327
      $a = 0.025;
328 328
 
329 329
      $b = 266;
330 330
 
331 331
     if ($year > 0) {
332
-        $leapDays0 = (($year + 38) % 2820)*0.24219 + $a;  // 0.24219 ~ extra days of one year
333
-        $leapDays1 = (($year + 39) % 2820)*0.24219 + $a;  // 38 days is the difference of epoch to 2820-year cycle
334
-    } elseif($year < 0 ) {
335
-        $leapDays0 = (($year + 39) % 2820)*0.24219 + $a;
336
-        $leapDays1 = (($year + 40) % 2820)*0.24219 + $a;
332
+        $leapDays0 = (($year + 38) % 2820) * 0.24219 + $a; // 0.24219 ~ extra days of one year
333
+        $leapDays1 = (($year + 39) % 2820) * 0.24219 + $a; // 38 days is the difference of epoch to 2820-year cycle
334
+    } elseif ($year < 0) {
335
+        $leapDays0 = (($year + 39) % 2820) * 0.24219 + $a;
336
+        $leapDays1 = (($year + 40) % 2820) * 0.24219 + $a;
337 337
     } else {
338 338
         return false;
339 339
     }
340 340
 
341
-     $frac0 = intval(($leapDays0 - intval($leapDays0))*1000);
342
-     $frac1 = intval(($leapDays1 - intval($leapDays1))*1000);
341
+     $frac0 = intval(($leapDays0 - intval($leapDays0)) * 1000);
342
+     $frac1 = intval(($leapDays1 - intval($leapDays1)) * 1000);
343 343
 
344 344
     if ($frac0 <= $b && $frac1 > $b) {
345 345
         return true; 
@@ -358,6 +358,6 @@  discard block
 block discarded – undo
358 358
    *
359 359
    *\_________________________________________________________/
360 360
    */
361
-  'weekend' => array( 'friday' )
361
+  'weekend' => array('friday')
362 362
 
363 363
  );
Please login to merge, or discard this patch.
src/CalendarSettings/Gregorian.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@  discard block
 block discarded – undo
4 4
 
5 5
  return [
6 6
 
7
- 'numbers' => array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'),
7
+ 'numbers' => array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'),
8 8
 
9 9
  'am_time' => 'AM',
10 10
 
11 11
  'pm_time' => 'PM',
12 12
 
13
- 'end_of_days' => array( 'th', 'st', 'nd', 'rd' ),
13
+ 'end_of_days' => array('th', 'st', 'nd', 'rd'),
14 14
 
15 15
 
16 16
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
   *
23 23
   *\_________________________________________________________/
24 24
   */
25
-   'convert_to' => function ($date_time) {
25
+   'convert_to' => function($date_time) {
26 26
 
27 27
      return null;
28 28
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     *
37 37
     *\_________________________________________________________/
38 38
     */
39
-    'convert_from' => function ($date_time) {
39
+    'convert_from' => function($date_time) {
40 40
 
41 41
         return null;
42 42
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     *
98 98
     *\_________________________________________________________/
99 99
     */
100
-    'days_of_week' => array (
100
+    'days_of_week' => array(
101 101
 
102 102
        'Monday',
103 103
        'Tuesday',
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     ),
110 110
 
111 111
 
112
-    'month_days_number' => array(   1 => 31,
112
+    'month_days_number' => array(1 => 31,
113 113
                                    2 => 28,
114 114
                                    3 => 31,
115 115
                                    4 => 30,
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
                                    9 => 30,
121 121
                                    10 => 31,
122 122
                                    11 => 30,
123
-                                   12 => 30 ),
123
+                                   12 => 30),
124 124
 
125 125
 
126
-    'day_of_year' => function ($date_time) {
126
+    'day_of_year' => function($date_time) {
127 127
 
128 128
         $result = null;
129 129
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
     },
149 149
 
150
-    'day_of_week' => function ($date_time) {
150
+    'day_of_week' => function($date_time) {
151 151
 
152 152
         $config = include 'Gregorian.php';
153 153
 
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
     *
170 170
     *\_________________________________________________________/
171 171
     */
172
-    'leap_year' => function ($year) {
172
+    'leap_year' => function($year) {
173 173
 
174
-        return ( ( ( $year % 4 ) == 0 ) && ( ( ( $year % 100 ) != 0 ) || ( ( $year % 400 ) == 0 ) ) );
174
+        return ((($year % 4) == 0) && ((($year % 100) != 0) || (($year % 400) == 0)));
175 175
 
176 176
     },
177 177
 
@@ -183,6 +183,6 @@  discard block
 block discarded – undo
183 183
     *
184 184
     *\_________________________________________________________/
185 185
     */
186
-    'weekend' => array( 'saturday', 'sunday' ),
186
+    'weekend' => array('saturday', 'sunday'),
187 187
 
188 188
   ];
Please login to merge, or discard this patch.
src/Config.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@
 block discarded – undo
35 35
   'default_calendar' => 'gregorian',
36 36
 
37 37
 
38
-  'date_interval' => array( 'D', 'M', 'Y', 'HT', 'MT', 'ST' ),
38
+  'date_interval' => array('D', 'M', 'Y', 'HT', 'MT', 'ST'),
39 39
 
40 40
 
41
-  'date_simple' => array( 'day', ' month', ' year', ' hour', ' minute', ' second' ),
41
+  'date_simple' => array('day', ' month', ' year', ' hour', ' minute', ' second'),
42 42
 
43 43
  );
Please login to merge, or discard this patch.
src/Lang.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
         /**
50 50
         * Fetch translated expression to langTable attribute
51 51
         */
52
-        self::$langTable = include 'lang/' . $language . '/general.php';
52
+        self::$langTable = include 'lang/'.$language.'/general.php';
53 53
 
54 54
         foreach (self::$langTable as $key => $translate) {
55
-            if (isset(self::$config[ $key ])) {
56
-                if (self::$config[ $key ]) {
57
-                    self::$config[ $key ] = $translate;
55
+            if (isset(self::$config[$key])) {
56
+                if (self::$config[$key]) {
57
+                    self::$config[$key] = $translate;
58 58
                 }
59 59
             }
60 60
         }
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
 
69 69
     }
70 70
 
71
-    public static function get( $lang, $value ) {
71
+    public static function get($lang, $value) {
72 72
 
73
-      $file = include( 'lang/' . $lang . '/general.php' );
73
+      $file = include('lang/'.$lang.'/general.php');
74 74
 
75 75
       return $file[$value];
76 76
 
Please login to merge, or discard this patch.
src/Datium.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 
114 114
         $this->config = include 'Config.php';
115 115
 
116
-        $this->calendar_type = $this->config[ 'default_calendar' ];
116
+        $this->calendar_type = $this->config['default_calendar'];
117 117
 
118
-        date_default_timezone_set($this->config[ 'timezone' ]);
118
+        date_default_timezone_set($this->config['timezone']);
119 119
 
120 120
         $this->calendar_type = 'gregorian';
121 121
 
@@ -131,15 +131,15 @@  discard block
 block discarded – undo
131 131
             $this->date_time = new DateTime('now');
132 132
 
133 133
             $this->date_time->setDate(
134
-                self::$array_date[ 'year' ],
135
-                self::$array_date[ 'month' ],
136
-                self::$array_date[ 'day' ]
134
+                self::$array_date['year'],
135
+                self::$array_date['month'],
136
+                self::$array_date['day']
137 137
             );
138 138
 
139 139
             $this->date_time->setTime(
140
-                self::$array_date[ 'hour' ],
141
-                self::$array_date[ 'minute' ],
142
-                self::$array_date[ 'second' ]
140
+                self::$array_date['hour'],
141
+                self::$array_date['minute'],
142
+                self::$array_date['second']
143 143
             );
144 144
 
145 145
             $this->gregorian_DayofWeek = $this->date_time->format('w');
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
     public function all()
165 165
     {
166 166
 
167
-        return ( object ) array(
167
+        return (object) array(
168 168
 
169 169
         'second' => $this->date_time->format('s'),
170 170
 
@@ -341,16 +341,16 @@  discard block
 block discarded – undo
341 341
     {
342 342
 
343 343
         $this->date_interval_expression = str_replace(
344
-            $this->config[ 'date_simple' ],
345
-            $this->config[ 'date_interval' ],
344
+            $this->config['date_simple'],
345
+            $this->config['date_interval'],
346 346
             $value
347 347
         );
348 348
 
349 349
         $unit = 'P';
350 350
 
351
-        if( strpos($this->date_interval_expression, 'T') ) {
351
+        if (strpos($this->date_interval_expression, 'T')) {
352 352
 
353
-          $this->date_interval_expression= str_replace(
353
+          $this->date_interval_expression = str_replace(
354 354
             'T',
355 355
             '',
356 356
             $this->date_interval_expression
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
         $this->date_interval_expression = str_replace(
364 364
             ' ',
365 365
             '',
366
-            $unit . $this->date_interval_expression
366
+            $unit.$this->date_interval_expression
367 367
         );
368 368
 
369 369
         $this->date_time->add(
@@ -385,16 +385,16 @@  discard block
 block discarded – undo
385 385
     {
386 386
 
387 387
         $this->date_interval_expression = str_replace(
388
-            $this->config[ 'date_simple' ],
389
-            $this->config[ 'date_interval' ],
388
+            $this->config['date_simple'],
389
+            $this->config['date_interval'],
390 390
             $value
391 391
         );
392 392
 
393 393
         $unit = 'P';
394 394
 
395
-        if( strpos($this->date_interval_expression, 'T') ) {
395
+        if (strpos($this->date_interval_expression, 'T')) {
396 396
 
397
-          $this->date_interval_expression= str_replace(
397
+          $this->date_interval_expression = str_replace(
398 398
             'T',
399 399
             '',
400 400
             $this->date_interval_expression
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
         $this->date_interval_expression = str_replace(
408 408
             ' ',
409 409
             '',
410
-            $unit . $this->date_interval_expression
410
+            $unit.$this->date_interval_expression
411 411
         );
412 412
 
413 413
         $this->date_time->sub(
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     public function ago()
443 443
     {
444 444
 
445
-      $this->ago = new TimeAgo( $this->date_time, $this->language );
445
+      $this->ago = new TimeAgo($this->date_time, $this->language);
446 446
 
447 447
       return $this->ago->get();
448 448
 
@@ -546,52 +546,52 @@  discard block
 block discarded – undo
546 546
         // $this->translate_to_file = include( 'Lang/' . $this->language . '/general.php' );
547 547
 
548 548
         if (is_null($this->fromConfig)) {
549
-            $this->fromConfig = include 'CalendarSettings/' .
550
-                                ucfirst($this->translate_from) . '.php';
549
+            $this->fromConfig = include 'CalendarSettings/'.
550
+                                ucfirst($this->translate_from).'.php';
551 551
         }
552 552
 
553 553
 
554 554
         if (is_null($this->toConfig)) {
555
-            $this->toConfig = include 'CalendarSettings/' .
556
-                                       ucfirst($this->translate_to) . '.php';
555
+            $this->toConfig = include 'CalendarSettings/'.
556
+                                       ucfirst($this->translate_to).'.php';
557 557
         }
558 558
 
559 559
         $string_date = $this->date_time->format($format);
560 560
 
561 561
         if ($this->translate_to != 'gregorian') {
562 562
             $string_date = str_replace(
563
-                $this->fromConfig[ 'month' ],
564
-                $this->toConfig[ 'month' ],
563
+                $this->fromConfig['month'],
564
+                $this->toConfig['month'],
565 565
                 $string_date
566 566
             );
567 567
 
568 568
             $string_date = str_replace(
569
-                $this->fromConfig[ 'days_of_week' ],
570
-                $this->toConfig[ 'days_of_week' ][ $this->gregorian_DayofWeek ],
569
+                $this->fromConfig['days_of_week'],
570
+                $this->toConfig['days_of_week'][$this->gregorian_DayofWeek],
571 571
                 $string_date
572 572
             );
573 573
 
574 574
             $string_date = str_replace(
575
-                $this->fromConfig[ 'numbers' ],
576
-                $this->toConfig[ 'numbers' ],
575
+                $this->fromConfig['numbers'],
576
+                $this->toConfig['numbers'],
577 577
                 $string_date
578 578
             );
579 579
 
580 580
             $string_date = str_replace(
581
-                $this->fromConfig[ 'am_time' ],
582
-                $this->toConfig[ 'am_time' ],
581
+                $this->fromConfig['am_time'],
582
+                $this->toConfig['am_time'],
583 583
                 $string_date
584 584
             );
585 585
 
586 586
             $string_date = str_replace(
587
-                $this->fromConfig[ 'pm_time' ],
588
-                $this->toConfig[ 'pm_time' ],
587
+                $this->fromConfig['pm_time'],
588
+                $this->toConfig['pm_time'],
589 589
                 $string_date
590 590
             );
591 591
 
592 592
             $string_date = str_replace(
593
-                $this->fromConfig[ 'end_of_days' ],
594
-                $this->toConfig[ 'end_of_days' ],
593
+                $this->fromConfig['end_of_days'],
594
+                $this->toConfig['end_of_days'],
595 595
                 $string_date
596 596
             );
597 597
         }
Please login to merge, or discard this patch.