Completed
Push — master ( 3848cb...1f8425 )
by mehdi
02:54
created
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 2 patches
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -36,17 +36,17 @@  discard block
 block discarded – undo
36 36
 {
37 37
 
38 38
     /**
39
-   * Store DateTime object
40
-   */
39
+     * Store DateTime object
40
+     */
41 41
     protected $date_time;
42 42
 
43 43
     protected static $static_date_time;
44 44
 
45 45
     /**
46
-   * Store config file statements
47
-   *
48
-   * @param array
49
-   */
46
+     * Store config file statements
47
+     *
48
+     * @param array
49
+     */
50 50
     protected $config;
51 51
 
52 52
     protected $date_interval_expression;
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
     protected $fromConfig;
65 65
 
66 66
     /**
67
-   * Return store day number
68
-   *
69
-   * @param integer
70
-   */
67
+     * Return store day number
68
+     *
69
+     * @param integer
70
+     */
71 71
     protected $day_of;
72 72
 
73 73
     protected $leap;
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
     protected $language;
94 94
 
95 95
     /**
96
-    * Timeago
97
-    *
98
-    * @param integer
99
-    */
96
+     * Timeago
97
+     *
98
+     * @param integer
99
+     */
100 100
     protected $ago;
101 101
 
102 102
     /**
103
-    * Datium class constructure
104
-    */
103
+     * Datium class constructure
104
+     */
105 105
     public function __construct()
106 106
     {
107 107
 
@@ -157,10 +157,10 @@  discard block
 block discarded – undo
157 157
     }
158 158
 
159 159
     /**
160
-    * Return all datetime parts as an object
161
-    *
162
-    * @return object
163
-    */
160
+     * Return all datetime parts as an object
161
+     *
162
+     * @return object
163
+     */
164 164
     public function all()
165 165
     {
166 166
 
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
     }
184 184
 
185 185
     /**
186
-   * Get current datetime
187
-   *
188
-   * @since  Aug 17 2015
189
-   * @return object
190
-   */
186
+     * Get current datetime
187
+     *
188
+     * @since  Aug 17 2015
189
+     * @return object
190
+     */
191 191
     public static function now()
192 192
     {
193 193
 
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
     }
199 199
 
200 200
     /**
201
-   * Create new date time
202
-   *
203
-   * @param integer $year   Year number
204
-   * @param integer $month  month number
205
-   * @param integer $day    day number
206
-   * @param integer $hour   hour number
207
-   * @param integer $minute minute number
208
-   * @param integer $second second number
209
-   *
210
-   * @return object
211
-   */
201
+     * Create new date time
202
+     *
203
+     * @param integer $year   Year number
204
+     * @param integer $month  month number
205
+     * @param integer $day    day number
206
+     * @param integer $hour   hour number
207
+     * @param integer $minute minute number
208
+     * @param integer $second second number
209
+     *
210
+     * @return object
211
+     */
212 212
     public static function create(
213 213
         $year = 2000,
214 214
         $month = 1,
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 
221 221
 
222 222
         /**
223
-       * When we want to set a Datetime object to Datium
224
-       */
223
+         * When we want to set a Datetime object to Datium
224
+         */
225 225
         if (func_num_args() === 1) {
226 226
             self::$static_date_time = func_get_arg(0);
227 227
 
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
     }
245 245
 
246 246
     /**
247
-    * Select The range between two date object
248
-    *
249
-    * @param object $date_start Start of the DateTime
250
-    * @param object $date_end   End of the DateTime
251
-    *
252
-    * @return object
253
-    */
247
+     * Select The range between two date object
248
+     *
249
+     * @param object $date_start Start of the DateTime
250
+     * @param object $date_end   End of the DateTime
251
+     *
252
+     * @return object
253
+     */
254 254
     public static function between($date_start, $date_end)
255 255
     {
256 256
 
@@ -265,12 +265,12 @@  discard block
 block discarded – undo
265 265
     }
266 266
 
267 267
     /**
268
-   * Convert from current calendar, what type is current calendar?
269
-   *
270
-   * @param object $calendar Assigned calendar to start from
271
-   *
272
-   * @return $object
273
-   */
268
+     * Convert from current calendar, what type is current calendar?
269
+     *
270
+     * @param object $calendar Assigned calendar to start from
271
+     *
272
+     * @return $object
273
+     */
274 274
     public function from($calendar)
275 275
     {
276 276
 
@@ -280,8 +280,8 @@  discard block
 block discarded – undo
280 280
 
281 281
 
282 282
         /**
283
-     * We need this part for DayOf class
284
-     */
283
+         * We need this part for DayOf class
284
+         */
285 285
         $this->calendar_type = $calendar;
286 286
 
287 287
         $this->translate_to = $calendar;
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
     }
292 292
 
293 293
     /**
294
-    * Convert date to current Date
295
-    *
296
-    * @param object $calendar Assigned calendar to when calendar should start.
297
-    *
298
-    * @return object
299
-    */
294
+     * Convert date to current Date
295
+     *
296
+     * @param object $calendar Assigned calendar to when calendar should start.
297
+     *
298
+     * @return object
299
+     */
300 300
     public function to($calendar)
301 301
     {
302 302
 
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
         $this->date_time = $this->convert->to($calendar);
306 306
 
307 307
         /**
308
-     * We need this part for DayOf class
309
-     */
308
+         * We need this part for DayOf class
309
+         */
310 310
         $this->calendar_type = $calendar;
311 311
 
312 312
         $this->translate_to = $calendar;
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
     }
317 317
 
318 318
     /**
319
-   * Difference between two time
320
-   *
321
-   * @param DateTime $start Start of the date
322
-   * @param DateTime $end   End of the date
323
-   *
324
-   * @return object
325
-   */
319
+     * Difference between two time
320
+     *
321
+     * @param DateTime $start Start of the date
322
+     * @param DateTime $end   End of the date
323
+     *
324
+     * @return object
325
+     */
326 326
     public static function diff($start, $end)
327 327
     {
328 328
 
@@ -331,12 +331,12 @@  discard block
 block discarded – undo
331 331
     }
332 332
 
333 333
     /**
334
-   * Add new date value to current date
335
-   *
336
-   * @param string $value How much date should be added to current date
337
-   *
338
-   * @return object
339
-   */
334
+     * Add new date value to current date
335
+     *
336
+     * @param string $value How much date should be added to current date
337
+     *
338
+     * @return object
339
+     */
340 340
     public function add($value)
341 341
     {
342 342
 
@@ -375,12 +375,12 @@  discard block
 block discarded – undo
375 375
     }
376 376
 
377 377
     /**
378
-   * Sub date from current date
379
-   *
380
-   * @param string $value How much date should increase from current date
381
-   *
382
-   * @return obejct
383
-   */
378
+     * Sub date from current date
379
+     *
380
+     * @param string $value How much date should increase from current date
381
+     *
382
+     * @return obejct
383
+     */
384 384
     public function sub($value)
385 385
     {
386 386
 
@@ -419,12 +419,12 @@  discard block
 block discarded – undo
419 419
     }
420 420
 
421 421
     /**
422
-   * Check if current year is leap or not
423
-   *
424
-   * @param string $type Name of the calendar to caculate leap year
425
-   *
426
-   * @return boolean
427
-   */
422
+     * Check if current year is leap or not
423
+     *
424
+     * @param string $type Name of the calendar to caculate leap year
425
+     *
426
+     * @return boolean
427
+     */
428 428
     public function leap()
429 429
     {
430 430
 
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
     }
436 436
 
437 437
     /**
438
-    * Calculate how many time ago datetime happens
439
-    *
440
-    * @return string
441
-    */
438
+     * Calculate how many time ago datetime happens
439
+     *
440
+     * @return string
441
+     */
442 442
     public function ago()
443 443
     {
444 444
 
@@ -449,12 +449,12 @@  discard block
 block discarded – undo
449 449
     }
450 450
 
451 451
     /**
452
-    * Caculate day of year or week
453
-    *
454
-    * @since Aug, 22 2015
455
-    *
456
-    * @return integer
457
-    */
452
+     * Caculate day of year or week
453
+     *
454
+     * @since Aug, 22 2015
455
+     *
456
+     * @return integer
457
+     */
458 458
     public function dayOf()
459 459
     {
460 460
 
@@ -482,12 +482,12 @@  discard block
 block discarded – undo
482 482
     // }
483 483
 
484 484
     /**
485
-    * Return Datetime as a original object
486
-    *
487
-    * @since Oct 22, 2015
488
-    *
489
-    * @return object
490
-    */
485
+     * Return Datetime as a original object
486
+     *
487
+     * @since Oct 22, 2015
488
+     *
489
+     * @return object
490
+     */
491 491
     public function object()
492 492
     {
493 493
 
@@ -496,12 +496,12 @@  discard block
 block discarded – undo
496 496
     }
497 497
 
498 498
     /**
499
-    * Translate current date string to selected language
500
-    *
501
-    * @param string $language language short name fa, en, ar ...
502
-    *
503
-    * @return object
504
-    */
499
+     * Translate current date string to selected language
500
+     *
501
+     * @param string $language language short name fa, en, ar ...
502
+     *
503
+     * @return object
504
+     */
505 505
     public function lang($language = 'fa')
506 506
     {
507 507
 
@@ -518,10 +518,10 @@  discard block
 block discarded – undo
518 518
     }
519 519
 
520 520
     /**
521
-    * Return object as timestamp
522
-    *
523
-    * @return timestamp
524
-    */
521
+     * Return object as timestamp
522
+     *
523
+     * @return timestamp
524
+     */
525 525
     public function timestamp()
526 526
     {
527 527
 
@@ -530,14 +530,14 @@  discard block
 block discarded – undo
530 530
     }
531 531
 
532 532
     /**
533
-   * Return fainal result
534
-   *
535
-   * @param string $format Date format
536
-   *
537
-   * @since Aug 17 2015
538
-   *
539
-   * @return string
540
-   */
533
+     * Return fainal result
534
+     *
535
+     * @param string $format Date format
536
+     *
537
+     * @since Aug 17 2015
538
+     *
539
+     * @return string
540
+     */
541 541
     public function get($format = 'Y-m-d H:i:s')
542 542
     {
543 543
 
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 
554 554
         if (is_null($this->toConfig)) {
555 555
             $this->toConfig = include 'CalendarSettings/' .
556
-                                       ucfirst($this->translate_to) . '.php';
556
+                                        ucfirst($this->translate_to) . '.php';
557 557
         }
558 558
 
559 559
         $string_date = $this->date_time->format($format);
Please login to merge, or discard this 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.