Completed
Push — master ( 5981e6...969234 )
by mehdi
02:52
created
src/Events/Events.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php namespace Datium;
2 2
 
3 3
 use Datium\Tools\Convert;
4
-use Datium\Tools\DayOf;
5 4
 use DateTime;
6 5
 use DateInterval;
7 6
 use DatePeriod;
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
 
28 28
     private static $date_end;
29 29
 
30
-    public function __construct( $date_time, $date_end = null ) 
30
+    public function __construct($date_time, $date_end = null) 
31 31
     {
32 32
 
33
-        if($date_end !== null ) {
33
+        if ($date_end !== null) {
34 34
 
35 35
             Events::$date_start = $date_time;
36 36
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     *
59 59
     *\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
60 60
     */
61
-    private function fetch( $path ) 
61
+    private function fetch($path) 
62 62
     {
63 63
 
64 64
         $this->events = include $path;
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 
68 68
         $this->period = new DatePeriod(Events::$date_start, $this->interval, Events::$date_end);
69 69
 
70
-        foreach ( $this->period as $dt ) {
70
+        foreach ($this->period as $dt) {
71 71
 
72
-            if (isset($this->events[ 'events' ][ intval($dt->format('m')) ][ intval($dt->format('d')) ]) ) {
72
+            if (isset($this->events['events'][intval($dt->format('m'))][intval($dt->format('d'))])) {
73 73
 
74
-                $this->result[ $dt->format('Y-m-d') ][] = $this->events[ 'events' ][ intval($dt->format('m')) ][ intval($dt->format('d')) ];
74
+                $this->result[$dt->format('Y-m-d')][] = $this->events['events'][intval($dt->format('m'))][intval($dt->format('d'))];
75 75
 
76 76
             }
77 77
 
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
     public function get() 
92 92
     {
93 93
 
94
-        if(! empty($this->result) ) {
94
+        if ( ! empty($this->result)) {
95 95
 
96
-            foreach( $this->result as $key => $day ) {
96
+            foreach ($this->result as $key => $day) {
97 97
 
98
-                if (! ( $key > Events::$date_start->format('Y-m-d') && $key < Events::$date_end->format('Y-m-d') ) ) {
98
+                if ( ! ($key > Events::$date_start->format('Y-m-d') && $key < Events::$date_end->format('Y-m-d'))) {
99 99
 
100
-                    unset($this->result[ $key ]);
100
+                    unset($this->result[$key]);
101 101
 
102 102
                 }
103 103
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     *
123 123
     *\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
124 124
     */
125
-    public function local( $country_code = "ir" ) 
125
+    public function local($country_code = "ir") 
126 126
     {
127 127
 
128 128
         /*
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
          */
132 132
         $country_code = strtolower($country_code = 'ir');
133 133
 
134
-        $this->local = include 'Localization/' . $country_code . '.php';
134
+        $this->local = include 'Localization/'.$country_code.'.php';
135 135
 
136
-        foreach( $this->local[ 'events' ] as $month => $events ) {
136
+        foreach ($this->local['events'] as $month => $events) {
137 137
 
138
-            foreach( $events as $day => $event ){
138
+            foreach ($events as $day => $event) {
139 139
 
140 140
                 $this->date_time = new DateTime();
141 141
 
142 142
                 $this->date_time->setDate(Events::$date_start->format('Y'), $month, $day);
143 143
 
144
-                switch ( $this->local[ 'default_calendar' ] ) {
144
+                switch ($this->local['default_calendar']) {
145 145
 
146 146
                 case 'jalali':
147 147
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
                 }
161 161
 
162
-                $this->result[ $this->date_time->format('Y-m-d') ][] =  $event;
162
+                $this->result[$this->date_time->format('Y-m-d')][] = $event;
163 163
 
164 164
             }
165 165
 
Please login to merge, or discard this patch.
src/Events/Global/global.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      * @link http://www.un.org/en/sections/observances/international-days/
14 14
      */
15 15
     'events' => array(
16
-      1 => array( 27 => 'International Day of Commemoration in Memory of the Victims of the Holocaust' ),
16
+      1 => array(27 => 'International Day of Commemoration in Memory of the Victims of the Holocaust'),
17 17
       2 => array(
18 18
         4 => 'World Cancer Day',
19 19
         6 => 'International Day of Zero Tolerance to Female Genital Mutilation',
Please login to merge, or discard this patch.
src/Events/Localization/ir.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@
 block discarded – undo
12 12
      * as a arraye value
13 13
      */
14 14
     'events' => array(
15
-      1 => array( 1 => 'nowruz', 2 => 'nowruz', 3 => 'nowruz', 5 => 'nowruz' ),
16
-      10 => array( 22 => 'Iran revelution day' ),
17
-      12 => array( 29 => 'Iran oil national day' )
15
+      1 => array(1 => 'nowruz', 2 => 'nowruz', 3 => 'nowruz', 5 => 'nowruz'),
16
+      10 => array(22 => 'Iran revelution day'),
17
+      12 => array(29 => 'Iran oil national day')
18 18
     ),
19 19
 
20 20
 );
Please login to merge, or discard this patch.
src/Events/Localization/us.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@
 block discarded – undo
9 9
 
10 10
   'events' => array(
11 11
 
12
-    4  => array( 22 => 'Earth day' ),
12
+    4  => array(22 => 'Earth day'),
13 13
 
14
-    12 => array( 25 => 'Christmas' )
14
+    12 => array(25 => 'Christmas')
15 15
 
16 16
   )
17 17
 
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', 'H', 'm', 'S' ),
38
+  'date_interval' => array('D', 'M', 'Y', 'H', 'm', 'S'),
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/ar/general.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
   return array(
4 4
 
5
-       'events' => array( 'eid fitr' => 'عيد الفطر',
5
+       'events' => array('eid fitr' => 'عيد الفطر',
6 6
 
7 7
                         ),
8 8
 
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
 
38 38
         'pm_time' => '',
39 39
 
40
-        'end_of_days' => array( "" ),
40
+        'end_of_days' => array(""),
41 41
 
42
-        'numbers' => array( '۰', '۱', '۲', '۳', '٤‎', '٥‎', '٦‎', '۷', '۸', '۹'),
42
+        'numbers' => array('۰', '۱', '۲', '۳', '٤‎', '٥‎', '٦‎', '۷', '۸', '۹'),
43 43
 
44 44
   );
45 45
 
Please login to merge, or discard this patch.
src/lang/fa/general.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
   return array(
4 4
 
5
-       'events' => array( 'nowruz' => 'عید نوروز',
5
+       'events' => array('nowruz' => 'عید نوروز',
6 6
 
7 7
                           'iran_national_day' => 'روز جمهوری اسلامی',
8 8
 
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 
41 41
         'pm_time' => 'ب.ظ',
42 42
 
43
-        'end_of_days' => array( "" ),
43
+        'end_of_days' => array(""),
44 44
 
45
-        'numbers' => array( '۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹' ),
45
+        'numbers' => array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'),
46 46
         '0' => '۰',
47 47
         '1' => '۱',
48 48
         '2' => '۲',
Please login to merge, or discard this patch.
src/CalendarSettings/Gregorian.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,5 @@
 block discarded – undo
1 1
 ``<?php
2 2
 
3
- use OpenCafe\Datium as Datium;
4
-
5 3
  return array (
6 4
 
7 5
  'numbers' => array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'),
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 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
 
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
 
136 136
         $day = $date_time->format('d');
137 137
 
138
-        foreach( $config['month_days_number'] as $_month => $value ) {
138
+        foreach ($config['month_days_number'] as $_month => $value) {
139 139
 
140
-            if ($_month < $month ) { $result += $value;
140
+            if ($_month < $month) { $result += $value;
141 141
             }
142 142
 
143 143
         }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
     },
150 150
 
151
-    'day_of_week' => function ( $date_time ) {
151
+    'day_of_week' => function($date_time) {
152 152
 
153 153
         $config = include 'Gregorian.php';
154 154
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
         foreach ($config['days_of_week'] as $key => $value) {
158 158
 
159
-            if ($value == $day ) { return $key += 1;
159
+            if ($value == $day) { return $key += 1;
160 160
             }
161 161
 
162 162
         }
@@ -181,6 +181,6 @@  discard block
 block discarded – undo
181 181
     *
182 182
     *\_________________________________________________________/
183 183
     */
184
-    'weekend' => array( 'saturday', 'sunday' ),
184
+    'weekend' => array('saturday', 'sunday'),
185 185
 
186 186
   ];
Please login to merge, or discard this patch.
src/Datium.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,6 @@
 block discarded – undo
18 18
 use OpenCafe\Tools\Leap;
19 19
 use OpenCafe\Tools\DayOf;
20 20
 use OpenCafe\Tools\Lang;
21
-
22 21
 use OpenCafe\Datium;
23 22
 
24 23
 /**
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
 
106 106
         $this->config = include 'Config.php';
107 107
 
108
-        $this->calendar_type = $this->config[ 'default_calendar' ];
108
+        $this->calendar_type = $this->config['default_calendar'];
109 109
 
110
-        date_default_timezone_set($this->config[ 'timezone' ]);
110
+        date_default_timezone_set($this->config['timezone']);
111 111
 
112 112
         $this->calendar_type = 'gregorian';
113 113
 
114
-        switch( Datium::$call_type ) {
114
+        switch (Datium::$call_type) {
115 115
 
116 116
         case 'now':
117 117
 
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
             $this->date_time = new DateTime('now');
127 127
 
128 128
             $this->date_time->setDate(
129
-                self::$array_date[ 'year' ],
130
-                self::$array_date[ 'month' ],
131
-                self::$array_date[ 'day' ]
129
+                self::$array_date['year'],
130
+                self::$array_date['month'],
131
+                self::$array_date['day']
132 132
             );
133 133
 
134 134
             $this->date_time->setTime(
135
-                self::$array_date[ 'hour' ],
136
-                self::$array_date[ 'minute' ],
137
-                self::$array_date[ 'second' ]
135
+                self::$array_date['hour'],
136
+                self::$array_date['minute'],
137
+                self::$array_date['second']
138 138
             );
139 139
 
140 140
             $this->gregorian_DayofWeek = $this->date_time->format('w');
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     public function all()
162 162
     {
163 163
 
164
-        return ( object ) array(
164
+        return (object) array(
165 165
 
166 166
         'second' => $this->date_time->format('s'),
167 167
 
@@ -206,13 +206,13 @@  discard block
 block discarded – undo
206 206
    *
207 207
    * @return object
208 208
    */
209
-    public static function create( $year = 2000, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0 )
209
+    public static function create($year = 2000, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0)
210 210
     {
211 211
 
212 212
         /**
213 213
        * When we want to set a Datetime object to Datium
214 214
        */
215
-        if(func_num_args() === 1 ) {
215
+        if (func_num_args() === 1) {
216 216
 
217 217
             self::$static_date_time = func_get_arg(0);
218 218
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
     *
246 246
     * @return object
247 247
     */
248
-    public static function between( $date_start, $date_end )
248
+    public static function between($date_start, $date_end)
249 249
     {
250 250
 
251 251
         self::$date_start = $date_start;
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
    *
266 266
    * @return $object
267 267
    */
268
-    public function from( $calendar )
268
+    public function from($calendar)
269 269
     {
270 270
 
271 271
         $this->convert = new Convert($this->date_time);
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
     *
292 292
     * @return object
293 293
     */
294
-    public function to( $calendar )
294
+    public function to($calendar)
295 295
     {
296 296
 
297 297
         $this->convert = new Convert($this->date_time);
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
    *
319 319
    * @return object
320 320
    */
321
-    public static function diff( $start, $end )
321
+    public static function diff($start, $end)
322 322
     {
323 323
 
324 324
         return date_diff($start, $end);
@@ -332,19 +332,19 @@  discard block
 block discarded – undo
332 332
    *
333 333
    * @return object
334 334
    */
335
-    public function add( $value )
335
+    public function add($value)
336 336
     {
337 337
 
338 338
         $this->date_interval_expression = str_replace(
339
-            $this->config[ 'date_simple' ],
340
-            $this->config[ 'date_interval' ],
339
+            $this->config['date_simple'],
340
+            $this->config['date_interval'],
341 341
             $value
342 342
         );
343 343
 
344 344
         $this->date_interval_expression = str_replace(
345 345
             ' ',
346 346
             '',
347
-            'P' . $this->date_interval_expression
347
+            'P'.$this->date_interval_expression
348 348
         );
349 349
 
350 350
         $this->date_time->add(
@@ -362,19 +362,19 @@  discard block
 block discarded – undo
362 362
    *
363 363
    * @return obejct
364 364
    */
365
-    public function sub( $value )
365
+    public function sub($value)
366 366
     {
367 367
 
368 368
         $this->date_interval_expression = str_replace(
369
-            $this->config[ 'date_simple' ],
370
-            $this->config[ 'date_interval' ],
369
+            $this->config['date_simple'],
370
+            $this->config['date_interval'],
371 371
             $value
372 372
         );
373 373
 
374 374
         $this->date_interval_expression = str_replace(
375 375
             ' ',
376 376
             '',
377
-            'P' . $this->date_interval_expression
377
+            'P'.$this->date_interval_expression
378 378
         );
379 379
 
380 380
         $this->date_time->sub(
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
    *
393 393
    * @return boolean
394 394
    */
395
-    public function leap( $type = 'gregorian' )
395
+    public function leap($type = 'gregorian')
396 396
     {
397 397
 
398 398
         $this->leap = new Leap($this->date_time->format('Y'), $type);
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
     *
456 456
     * @return object
457 457
     */
458
-    public function lang( $language = 'fa' )
458
+    public function lang($language = 'fa')
459 459
     {
460 460
 
461 461
         $this->language = $language;
@@ -479,65 +479,65 @@  discard block
 block discarded – undo
479 479
    *
480 480
    * @return string
481 481
    */
482
-    public function get( $format = 'Y-m-d H:i:s' )
482
+    public function get($format = 'Y-m-d H:i:s')
483 483
     {
484 484
 
485 485
         // $this->translate_from_file = include( 'Lang/en/general.php' );
486 486
         //
487 487
         // $this->translate_to_file = include( 'Lang/' . $this->language . '/general.php' );
488 488
 
489
-        if (is_null($this->fromConfig) ) {
489
+        if (is_null($this->fromConfig)) {
490 490
 
491
-            $this->fromConfig = include 'CalendarSettings/' .
492
-                                ucfirst($this->translate_from) . '.php';
491
+            $this->fromConfig = include 'CalendarSettings/'.
492
+                                ucfirst($this->translate_from).'.php';
493 493
 
494 494
         }
495 495
 
496 496
 
497
-        if (is_null($this->toConfig) ) {
497
+        if (is_null($this->toConfig)) {
498 498
 
499
-            $this->toConfig = include 'CalendarSettings/' .
500
-                                       ucfirst($this->translate_to) . '.php';
499
+            $this->toConfig = include 'CalendarSettings/'.
500
+                                       ucfirst($this->translate_to).'.php';
501 501
 
502 502
         }
503 503
 
504 504
         $string_date = $this->date_time->format($format);
505 505
 
506
-        if ($this->translate_to != 'gregorian' ) {
506
+        if ($this->translate_to != 'gregorian') {
507 507
 
508 508
             $string_date = str_replace(
509
-                $this->fromConfig[ 'month' ],
510
-                $this->toConfig[ 'month' ],
509
+                $this->fromConfig['month'],
510
+                $this->toConfig['month'],
511 511
                 $string_date
512 512
             );
513 513
 
514 514
             $string_date = str_replace(
515
-                $this->fromConfig[ 'days_of_week' ],
516
-                $this->toConfig[ 'days_of_week' ][ $this->gregorian_DayofWeek ],
515
+                $this->fromConfig['days_of_week'],
516
+                $this->toConfig['days_of_week'][$this->gregorian_DayofWeek],
517 517
                 $string_date
518 518
             );
519 519
 
520 520
             $string_date = str_replace(
521
-                $this->fromConfig[ 'numbers' ],
522
-                $this->toConfig[ 'numbers' ],
521
+                $this->fromConfig['numbers'],
522
+                $this->toConfig['numbers'],
523 523
                 $string_date
524 524
             );
525 525
 
526 526
             $string_date = str_replace(
527
-                $this->fromConfig[ 'am_time' ],
528
-                $this->toConfig[ 'am_time' ],
527
+                $this->fromConfig['am_time'],
528
+                $this->toConfig['am_time'],
529 529
                 $string_date
530 530
             );
531 531
 
532 532
             $string_date = str_replace(
533
-                $this->fromConfig[ 'pm_time' ],
534
-                $this->toConfig[ 'pm_time' ],
533
+                $this->fromConfig['pm_time'],
534
+                $this->toConfig['pm_time'],
535 535
                 $string_date
536 536
             );
537 537
 
538 538
             $string_date = str_replace(
539
-                $this->fromConfig[ 'end_of_days' ],
540
-                $this->toConfig[ 'end_of_days' ],
539
+                $this->fromConfig['end_of_days'],
540
+                $this->toConfig['end_of_days'],
541 541
                 $string_date
542 542
             );
543 543
 
Please login to merge, or discard this patch.