Completed
Push — master ( e3b055...197347 )
by mehdi
02:54
created
src/Datium.php 3 patches
Doc Comments   +13 added lines, -14 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
    * Get current datetime
197 197
    *
198 198
    * @since  Aug 17 2015
199
-   * @return object
199
+   * @return Datium
200 200
    */
201 201
     public static function now()
202 202
     {
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
    * @param integer $minute minute number
218 218
    * @param integer $second second number
219 219
    *
220
-   * @return object
220
+   * @return Datium
221 221
    */
222 222
     public static function create(
223 223
         $year = 2000,
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
     * Accecpt Timestamp as Datium initializion
258 258
     *
259 259
     * @param  timestamp $timestamp Input timestamp value
260
-    * @return object
260
+    * @return Datium
261 261
     */
262 262
     public static function createTimestamp( $timestamp )
263 263
     {
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
     * @param object $date_start Start of the DateTime
287 287
     * @param object $date_end   End of the DateTime
288 288
     *
289
-    * @return object
289
+    * @return Datium
290 290
     */
291 291
     public static function between($date_start, $date_end)
292 292
     {
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
     *
333 333
     * @param object $calendar Assigned calendar to when calendar should start.
334 334
     *
335
-    * @return object
335
+    * @return Datium
336 336
     */
337 337
     public function to($calendar)
338 338
     {
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
    *
387 387
    * @param string $value How much date should be added to current date
388 388
    *
389
-   * @return object
389
+   * @return Datium
390 390
    */
391 391
     public function add($value)
392 392
     {
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
    *
429 429
    * @param string $value How much date should increase from current date
430 430
    *
431
-   * @return obejct
431
+   * @return Datium
432 432
    */
433 433
     public function sub($value)
434 434
     {
@@ -468,9 +468,8 @@  discard block
 block discarded – undo
468 468
     /**
469 469
    * Check if current year is leap or not
470 470
    *
471
-   * @param string $type Name of the calendar to caculate leap year
472 471
    *
473
-   * @return boolean
472
+   * @return Leap
474 473
    */
475 474
     public function leap()
476 475
     {
@@ -484,7 +483,7 @@  discard block
 block discarded – undo
484 483
     /**
485 484
     * Calculate how many time ago datetime happens
486 485
     *
487
-    * @return string
486
+    * @return TimeAgo
488 487
     */
489 488
     public function ago()
490 489
     {
@@ -500,7 +499,7 @@  discard block
 block discarded – undo
500 499
     *
501 500
     * @since Aug, 22 2015
502 501
     *
503
-    * @return integer
502
+    * @return DayOf
504 503
     */
505 504
     public function dayOf()
506 505
     {
@@ -533,7 +532,7 @@  discard block
 block discarded – undo
533 532
     *
534 533
     * @since Oct 22, 2015
535 534
     *
536
-    * @return object
535
+    * @return DateTime
537 536
     */
538 537
     public function object()
539 538
     {
@@ -547,7 +546,7 @@  discard block
 block discarded – undo
547 546
     *
548 547
     * @param string $language language short name fa, en, ar ...
549 548
     *
550
-    * @return object
549
+    * @return Datium
551 550
     */
552 551
     public function lang($language = 'fa')
553 552
     {
@@ -567,7 +566,7 @@  discard block
 block discarded – undo
567 566
     /**
568 567
     * Return object as timestamp
569 568
     *
570
-    * @return timestamp
569
+    * @return integer
571 570
     */
572 571
     public function timestamp()
573 572
     {
Please login to merge, or discard this patch.
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -34,17 +34,17 @@  discard block
 block discarded – undo
34 34
 {
35 35
 
36 36
     /**
37
-   * Store DateTime object
38
-   */
37
+     * Store DateTime object
38
+     */
39 39
     protected $date_time;
40 40
 
41 41
     protected static $static_date_time;
42 42
 
43 43
     /**
44
-   * Store config file statements
45
-   *
46
-   * @param array
47
-   */
44
+     * Store config file statements
45
+     *
46
+     * @param array
47
+     */
48 48
     protected $config;
49 49
 
50 50
     protected $date_interval_expression;
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
     protected $fromConfig;
63 63
 
64 64
     /**
65
-   * Return store day number
66
-   *
67
-   * @param integer
68
-   */
65
+     * Return store day number
66
+     *
67
+     * @param integer
68
+     */
69 69
     protected $day_of;
70 70
 
71 71
     protected $leap;
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
     protected static $timestamp;
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
 
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
     }
168 168
 
169 169
     /**
170
-    * Return all datetime parts as an object
171
-    *
172
-    * @return object
173
-    */
170
+     * Return all datetime parts as an object
171
+     *
172
+     * @return object
173
+     */
174 174
     public function all()
175 175
     {
176 176
 
@@ -193,11 +193,11 @@  discard block
 block discarded – undo
193 193
     }
194 194
 
195 195
     /**
196
-   * Get current datetime
197
-   *
198
-   * @since  Aug 17 2015
199
-   * @return object
200
-   */
196
+     * Get current datetime
197
+     *
198
+     * @since  Aug 17 2015
199
+     * @return object
200
+     */
201 201
     public static function now()
202 202
     {
203 203
 
@@ -208,17 +208,17 @@  discard block
 block discarded – undo
208 208
     }
209 209
 
210 210
     /**
211
-   * Create new date time
212
-   *
213
-   * @param integer $year   Year number
214
-   * @param integer $month  month number
215
-   * @param integer $day    day number
216
-   * @param integer $hour   hour number
217
-   * @param integer $minute minute number
218
-   * @param integer $second second number
219
-   *
220
-   * @return object
221
-   */
211
+     * Create new date time
212
+     *
213
+     * @param integer $year   Year number
214
+     * @param integer $month  month number
215
+     * @param integer $day    day number
216
+     * @param integer $hour   hour number
217
+     * @param integer $minute minute number
218
+     * @param integer $second second number
219
+     *
220
+     * @return object
221
+     */
222 222
     public static function create(
223 223
         $year = 2000,
224 224
         $month = 1,
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 
231 231
 
232 232
         /**
233
-       * When we want to set a Datetime object to Datium
234
-       */
233
+         * When we want to set a Datetime object to Datium
234
+         */
235 235
         if (func_num_args() === 1) {
236 236
             self::$static_date_time = func_get_arg(0);
237 237
 
@@ -254,11 +254,11 @@  discard block
 block discarded – undo
254 254
     }
255 255
 
256 256
     /**
257
-    * Accecpt Timestamp as Datium initializion
258
-    *
259
-    * @param  timestamp $timestamp Input timestamp value
260
-    * @return object
261
-    */
257
+     * Accecpt Timestamp as Datium initializion
258
+     *
259
+     * @param  timestamp $timestamp Input timestamp value
260
+     * @return object
261
+     */
262 262
     public static function createTimestamp( $timestamp )
263 263
     {
264 264
 
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
     }
282 282
 
283 283
     /**
284
-    * Select The range between two date object
285
-    *
286
-    * @param object $date_start Start of the DateTime
287
-    * @param object $date_end   End of the DateTime
288
-    *
289
-    * @return object
290
-    */
284
+     * Select The range between two date object
285
+     *
286
+     * @param object $date_start Start of the DateTime
287
+     * @param object $date_end   End of the DateTime
288
+     *
289
+     * @return object
290
+     */
291 291
     public static function between($date_start, $date_end)
292 292
     {
293 293
 
@@ -302,12 +302,12 @@  discard block
 block discarded – undo
302 302
     }
303 303
 
304 304
     /**
305
-   * Convert from current calendar, what type is current calendar?
306
-   *
307
-   * @param object $calendar Assigned calendar to start from
308
-   *
309
-   * @return $object
310
-   */
305
+     * Convert from current calendar, what type is current calendar?
306
+     *
307
+     * @param object $calendar Assigned calendar to start from
308
+     *
309
+     * @return $object
310
+     */
311 311
     public function from($calendar)
312 312
     {
313 313
 
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 
318 318
 
319 319
         /**
320
-     * We need this part for DayOf class
321
-     */
320
+         * We need this part for DayOf class
321
+         */
322 322
         $this->calendar_type = $calendar;
323 323
 
324 324
         $this->translate_to = $calendar;
@@ -328,12 +328,12 @@  discard block
 block discarded – undo
328 328
     }
329 329
 
330 330
     /**
331
-    * Convert date to current Date
332
-    *
333
-    * @param object $calendar Assigned calendar to when calendar should start.
334
-    *
335
-    * @return object
336
-    */
331
+     * Convert date to current Date
332
+     *
333
+     * @param object $calendar Assigned calendar to when calendar should start.
334
+     *
335
+     * @return object
336
+     */
337 337
     public function to($calendar)
338 338
     {
339 339
 
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
         $this->date_time = $this->convert->to($calendar);
343 343
 
344 344
         /**
345
-     * We need this part for DayOf class
346
-     */
345
+         * We need this part for DayOf class
346
+         */
347 347
         $this->calendar_type = $calendar;
348 348
 
349 349
         $this->translate_to = $calendar;
@@ -353,13 +353,13 @@  discard block
 block discarded – undo
353 353
     }
354 354
 
355 355
     /**
356
-   * Difference between two time
357
-   *
358
-   * @param DateTime $start Start of the date
359
-   * @param DateTime $end   End of the date
360
-   *
361
-   * @return object
362
-   */
356
+     * Difference between two time
357
+     *
358
+     * @param DateTime $start Start of the date
359
+     * @param DateTime $end   End of the date
360
+     *
361
+     * @return object
362
+     */
363 363
     public static function diff($start, $end)
364 364
     {
365 365
 
@@ -382,12 +382,12 @@  discard block
 block discarded – undo
382 382
     }
383 383
 
384 384
     /**
385
-   * Add new date value to current date
386
-   *
387
-   * @param string $value How much date should be added to current date
388
-   *
389
-   * @return object
390
-   */
385
+     * Add new date value to current date
386
+     *
387
+     * @param string $value How much date should be added to current date
388
+     *
389
+     * @return object
390
+     */
391 391
     public function add($value)
392 392
     {
393 393
 
@@ -424,12 +424,12 @@  discard block
 block discarded – undo
424 424
     }
425 425
 
426 426
     /**
427
-   * Sub date from current date
428
-   *
429
-   * @param string $value How much date should increase from current date
430
-   *
431
-   * @return obejct
432
-   */
427
+     * Sub date from current date
428
+     *
429
+     * @param string $value How much date should increase from current date
430
+     *
431
+     * @return obejct
432
+     */
433 433
     public function sub($value)
434 434
     {
435 435
 
@@ -466,12 +466,12 @@  discard block
 block discarded – undo
466 466
     }
467 467
 
468 468
     /**
469
-   * Check if current year is leap or not
470
-   *
471
-   * @param string $type Name of the calendar to caculate leap year
472
-   *
473
-   * @return boolean
474
-   */
469
+     * Check if current year is leap or not
470
+     *
471
+     * @param string $type Name of the calendar to caculate leap year
472
+     *
473
+     * @return boolean
474
+     */
475 475
     public function leap()
476 476
     {
477 477
 
@@ -482,10 +482,10 @@  discard block
 block discarded – undo
482 482
     }
483 483
 
484 484
     /**
485
-    * Calculate how many time ago datetime happens
486
-    *
487
-    * @return string
488
-    */
485
+     * Calculate how many time ago datetime happens
486
+     *
487
+     * @return string
488
+     */
489 489
     public function ago()
490 490
     {
491 491
 
@@ -496,12 +496,12 @@  discard block
 block discarded – undo
496 496
     }
497 497
 
498 498
     /**
499
-    * Caculate day of year or week
500
-    *
501
-    * @since Aug, 22 2015
502
-    *
503
-    * @return integer
504
-    */
499
+     * Caculate day of year or week
500
+     *
501
+     * @since Aug, 22 2015
502
+     *
503
+     * @return integer
504
+     */
505 505
     public function dayOf()
506 506
     {
507 507
 
@@ -529,12 +529,12 @@  discard block
 block discarded – undo
529 529
     // }
530 530
 
531 531
     /**
532
-    * Return Datetime as a original object
533
-    *
534
-    * @since Oct 22, 2015
535
-    *
536
-    * @return object
537
-    */
532
+     * Return Datetime as a original object
533
+     *
534
+     * @since Oct 22, 2015
535
+     *
536
+     * @return object
537
+     */
538 538
     public function object()
539 539
     {
540 540
 
@@ -543,12 +543,12 @@  discard block
 block discarded – undo
543 543
     }
544 544
 
545 545
     /**
546
-    * Translate current date string to selected language
547
-    *
548
-    * @param string $language language short name fa, en, ar ...
549
-    *
550
-    * @return object
551
-    */
546
+     * Translate current date string to selected language
547
+     *
548
+     * @param string $language language short name fa, en, ar ...
549
+     *
550
+     * @return object
551
+     */
552 552
     public function lang($language = 'fa')
553 553
     {
554 554
 
@@ -565,10 +565,10 @@  discard block
 block discarded – undo
565 565
     }
566 566
 
567 567
     /**
568
-    * Return object as timestamp
569
-    *
570
-    * @return timestamp
571
-    */
568
+     * Return object as timestamp
569
+     *
570
+     * @return timestamp
571
+     */
572 572
     public function timestamp()
573 573
     {
574 574
 
@@ -577,14 +577,14 @@  discard block
 block discarded – undo
577 577
     }
578 578
 
579 579
     /**
580
-   * Return fainal result
581
-   *
582
-   * @param string $format Date format
583
-   *
584
-   * @since Aug 17 2015
585
-   *
586
-   * @return string
587
-   */
580
+     * Return fainal result
581
+     *
582
+     * @param string $format Date format
583
+     *
584
+     * @since Aug 17 2015
585
+     *
586
+     * @return string
587
+     */
588 588
     public function get($format = 'Y-m-d H:i:s')
589 589
     {
590 590
 
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 
601 601
         if (is_null($this->toConfig)) {
602 602
             $this->toConfig = include 'CalendarSettings/' .
603
-                                       ucfirst($this->translate_to) . '.php';
603
+                                        ucfirst($this->translate_to) . '.php';
604 604
         }
605 605
 
606 606
         $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
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
                 $this->date_time = new DateTime();
128 128
 
129
-                $this->date_time->setTimestamp( self::$timestamp );
129
+                $this->date_time->setTimestamp(self::$timestamp);
130 130
 
131 131
                 break;
132 132
 
@@ -141,15 +141,15 @@  discard block
 block discarded – undo
141 141
                 $this->date_time = new DateTime('now');
142 142
 
143 143
                 $this->date_time->setDate(
144
-                    self::$array_date[ 'year' ],
145
-                    self::$array_date[ 'month' ],
146
-                    self::$array_date[ 'day' ]
144
+                    self::$array_date['year'],
145
+                    self::$array_date['month'],
146
+                    self::$array_date['day']
147 147
                 );
148 148
 
149 149
                 $this->date_time->setTime(
150
-                    self::$array_date[ 'hour' ],
151
-                    self::$array_date[ 'minute' ],
152
-                    self::$array_date[ 'second' ]
150
+                    self::$array_date['hour'],
151
+                    self::$array_date['minute'],
152
+                    self::$array_date['second']
153 153
                 );
154 154
 
155 155
                 break;
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     public function all()
175 175
     {
176 176
 
177
-        return ( object ) array(
177
+        return (object) array(
178 178
 
179 179
         'second' => $this->date_time->format('s'),
180 180
 
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
     * @param  timestamp $timestamp Input timestamp value
260 260
     * @return object
261 261
     */
262
-    public static function createTimestamp( $timestamp )
262
+    public static function createTimestamp($timestamp)
263 263
     {
264 264
 
265
-      if( $timestamp != null && is_int( $timestamp ) )
265
+      if ($timestamp != null && is_int($timestamp))
266 266
       {
267 267
 
268 268
         self::$call_type = 'create-timestamp';
@@ -392,15 +392,15 @@  discard block
 block discarded – undo
392 392
     {
393 393
 
394 394
         $this->date_interval_expression = str_replace(
395
-            $this->config[ 'date_simple' ],
396
-            $this->config[ 'date_interval' ],
395
+            $this->config['date_simple'],
396
+            $this->config['date_interval'],
397 397
             $value
398 398
         );
399 399
 
400 400
         $unit = 'P';
401 401
 
402 402
         if (strpos($this->date_interval_expression, 'T')) {
403
-            $this->date_interval_expression= str_replace(
403
+            $this->date_interval_expression = str_replace(
404 404
                 'T',
405 405
                 '',
406 406
                 $this->date_interval_expression
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
         $this->date_interval_expression = str_replace(
413 413
             ' ',
414 414
             '',
415
-            $unit . $this->date_interval_expression
415
+            $unit.$this->date_interval_expression
416 416
         );
417 417
 
418 418
         $this->date_time->add(
@@ -434,15 +434,15 @@  discard block
 block discarded – undo
434 434
     {
435 435
 
436 436
         $this->date_interval_expression = str_replace(
437
-            $this->config[ 'date_simple' ],
438
-            $this->config[ 'date_interval' ],
437
+            $this->config['date_simple'],
438
+            $this->config['date_interval'],
439 439
             $value
440 440
         );
441 441
 
442 442
         $unit = 'P';
443 443
 
444 444
         if (strpos($this->date_interval_expression, 'T')) {
445
-            $this->date_interval_expression= str_replace(
445
+            $this->date_interval_expression = str_replace(
446 446
                 'T',
447 447
                 '',
448 448
                 $this->date_interval_expression
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
         $this->date_interval_expression = str_replace(
455 455
             ' ',
456 456
             '',
457
-            $unit . $this->date_interval_expression
457
+            $unit.$this->date_interval_expression
458 458
         );
459 459
 
460 460
         $this->date_time->sub(
@@ -593,52 +593,52 @@  discard block
 block discarded – undo
593 593
         // $this->translate_to_file = include( 'Lang/' . $this->language . '/general.php' );
594 594
 
595 595
         if (is_null($this->fromConfig)) {
596
-            $this->fromConfig = include 'CalendarSettings/' .
597
-                                ucfirst($this->translate_from) . '.php';
596
+            $this->fromConfig = include 'CalendarSettings/'.
597
+                                ucfirst($this->translate_from).'.php';
598 598
         }
599 599
 
600 600
 
601 601
         if (is_null($this->toConfig)) {
602
-            $this->toConfig = include 'CalendarSettings/' .
603
-                                       ucfirst($this->translate_to) . '.php';
602
+            $this->toConfig = include 'CalendarSettings/'.
603
+                                       ucfirst($this->translate_to).'.php';
604 604
         }
605 605
 
606 606
         $string_date = $this->date_time->format($format);
607 607
 
608 608
         if ($this->translate_to != 'gregorian') {
609 609
             $string_date = str_replace(
610
-                $this->fromConfig[ 'month' ],
611
-                $this->toConfig[ 'month' ],
610
+                $this->fromConfig['month'],
611
+                $this->toConfig['month'],
612 612
                 $string_date
613 613
             );
614 614
 
615 615
             $string_date = str_replace(
616
-                $this->fromConfig[ 'days_of_week' ],
617
-                $this->toConfig[ 'days_of_week' ][ $this->gregorian_DayofWeek ],
616
+                $this->fromConfig['days_of_week'],
617
+                $this->toConfig['days_of_week'][$this->gregorian_DayofWeek],
618 618
                 $string_date
619 619
             );
620 620
 
621 621
             $string_date = str_replace(
622
-                $this->fromConfig[ 'numbers' ],
623
-                $this->toConfig[ 'numbers' ],
622
+                $this->fromConfig['numbers'],
623
+                $this->toConfig['numbers'],
624 624
                 $string_date
625 625
             );
626 626
 
627 627
             $string_date = str_replace(
628
-                $this->fromConfig[ 'am_time' ],
629
-                $this->toConfig[ 'am_time' ],
628
+                $this->fromConfig['am_time'],
629
+                $this->toConfig['am_time'],
630 630
                 $string_date
631 631
             );
632 632
 
633 633
             $string_date = str_replace(
634
-                $this->fromConfig[ 'pm_time' ],
635
-                $this->toConfig[ 'pm_time' ],
634
+                $this->fromConfig['pm_time'],
635
+                $this->toConfig['pm_time'],
636 636
                 $string_date
637 637
             );
638 638
 
639 639
             $string_date = str_replace(
640
-                $this->fromConfig[ 'end_of_days' ],
641
-                $this->toConfig[ 'end_of_days' ],
640
+                $this->fromConfig['end_of_days'],
641
+                $this->toConfig['end_of_days'],
642 642
                 $string_date
643 643
             );
644 644
         }
Please login to merge, or discard this patch.