@@ -34,8 +34,9 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * SimpleDiff Class constructure |
| 36 | 36 | * |
| 37 | - * @param DateTime $time_difference The time to calculate with now |
|
| 38 | - * @param string $lang Language |
|
| 37 | + * @param DateTime $difference The time to calculate with now |
|
| 38 | + * @param \DateTime $start |
|
| 39 | + * @param \DateTime $end |
|
| 39 | 40 | */ |
| 40 | 41 | public function __construct($start, $end, $difference ) |
| 41 | 42 | { |
@@ -65,8 +66,8 @@ discard block |
||
| 65 | 66 | /** |
| 66 | 67 | * Read ago config file |
| 67 | 68 | * |
| 68 | - * @param integer $date date index in ago config file |
|
| 69 | 69 | * @param string $type duration type on ago config file |
| 70 | + * @param integer $value |
|
| 70 | 71 | */ |
| 71 | 72 | public function read( $value, $type ) |
| 72 | 73 | { |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | private $blockList; |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * SimpleDiff Class constructure |
|
| 36 | - * |
|
| 37 | - * @param DateTime $time_difference The time to calculate with now |
|
| 38 | - * @param string $lang Language |
|
| 39 | - */ |
|
| 35 | + * SimpleDiff Class constructure |
|
| 36 | + * |
|
| 37 | + * @param DateTime $time_difference The time to calculate with now |
|
| 38 | + * @param string $lang Language |
|
| 39 | + */ |
|
| 40 | 40 | public function __construct($start, $end, $difference ) |
| 41 | 41 | { |
| 42 | 42 | |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | - * Return difference period as an object |
|
| 55 | - * |
|
| 56 | - * @return object |
|
| 57 | - */ |
|
| 54 | + * Return difference period as an object |
|
| 55 | + * |
|
| 56 | + * @return object |
|
| 57 | + */ |
|
| 58 | 58 | public function all() |
| 59 | 59 | { |
| 60 | 60 | |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | - * Read ago config file |
|
| 67 | - * |
|
| 68 | - * @param integer $date date index in ago config file |
|
| 69 | - * @param string $type duration type on ago config file |
|
| 70 | - */ |
|
| 66 | + * Read ago config file |
|
| 67 | + * |
|
| 68 | + * @param integer $date date index in ago config file |
|
| 69 | + * @param string $type duration type on ago config file |
|
| 70 | + */ |
|
| 71 | 71 | public function read( $value, $type ) |
| 72 | 72 | { |
| 73 | 73 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | if( array_key_exists( $value, $config[ $type ] ) ) { |
| 99 | 99 | |
| 100 | 100 | $str = Lang::get( $this->language, $config[ $type ][ $value ] ) |
| 101 | - . $time; |
|
| 101 | + . $time; |
|
| 102 | 102 | |
| 103 | 103 | return $str; |
| 104 | 104 | |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | - * Show priority of duration |
|
| 118 | - * |
|
| 119 | - * @param integer $date date index in ago config file |
|
| 120 | - * @param string $type duration type on ago config file |
|
| 121 | - */ |
|
| 117 | + * Show priority of duration |
|
| 118 | + * |
|
| 119 | + * @param integer $date date index in ago config file |
|
| 120 | + * @param string $type duration type on ago config file |
|
| 121 | + */ |
|
| 122 | 122 | public function priority( $date, $type ) |
| 123 | 123 | { |
| 124 | 124 | |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | - * Return fainal SimpleDiff result |
|
| 148 | - * |
|
| 149 | - * @return string |
|
| 150 | - */ |
|
| 147 | + * Return fainal SimpleDiff result |
|
| 148 | + * |
|
| 149 | + * @return string |
|
| 150 | + */ |
|
| 151 | 151 | public function get() |
| 152 | 152 | { |
| 153 | 153 | |
@@ -37,12 +37,12 @@ discard block |
||
| 37 | 37 | * @param DateTime $time_difference The time to calculate with now |
| 38 | 38 | * @param string $lang Language |
| 39 | 39 | */ |
| 40 | - public function __construct($start, $end, $difference ) |
|
| 40 | + public function __construct($start, $end, $difference) |
|
| 41 | 41 | { |
| 42 | 42 | |
| 43 | 43 | $this->language = 'en'; |
| 44 | 44 | |
| 45 | - $this->result = $difference; |
|
| 45 | + $this->result = $difference; |
|
| 46 | 46 | |
| 47 | 47 | $this->blockList = [ |
| 48 | 48 | 'just-now' |
@@ -68,46 +68,46 @@ discard block |
||
| 68 | 68 | * @param integer $date date index in ago config file |
| 69 | 69 | * @param string $type duration type on ago config file |
| 70 | 70 | */ |
| 71 | - public function read( $value, $type ) |
|
| 71 | + public function read($value, $type) |
|
| 72 | 72 | { |
| 73 | 73 | |
| 74 | - $config = include __DIR__ . '/config/diff.php'; |
|
| 74 | + $config = include __DIR__.'/config/diff.php'; |
|
| 75 | 75 | |
| 76 | - if( $this->result->invert ) { |
|
| 76 | + if ($this->result->invert) { |
|
| 77 | 77 | |
| 78 | - $time = ' ' . Lang::get( $this->language, 'remaining' ); |
|
| 78 | + $time = ' '.Lang::get($this->language, 'remaining'); |
|
| 79 | 79 | |
| 80 | 80 | } else { |
| 81 | 81 | |
| 82 | - $time = ' ' . Lang::get( $this->language, 'ago' ); |
|
| 82 | + $time = ' '.Lang::get($this->language, 'ago'); |
|
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if( isset( $config[ $type ][ $value ] ) && in_array( |
|
| 86 | + if (isset($config[$type][$value]) && in_array( |
|
| 87 | 87 | |
| 88 | - $config[ $type ][ $value ], |
|
| 88 | + $config[$type][$value], |
|
| 89 | 89 | |
| 90 | 90 | $this->blockList |
| 91 | 91 | |
| 92 | - ) ) { |
|
| 92 | + )) { |
|
| 93 | 93 | |
| 94 | 94 | $time = null; |
| 95 | 95 | |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if( array_key_exists( $value, $config[ $type ] ) ) { |
|
| 98 | + if (array_key_exists($value, $config[$type])) { |
|
| 99 | 99 | |
| 100 | - $str = Lang::get( $this->language, $config[ $type ][ $value ] ) |
|
| 100 | + $str = Lang::get($this->language, $config[$type][$value]) |
|
| 101 | 101 | . $time; |
| 102 | 102 | |
| 103 | 103 | return $str; |
| 104 | 104 | |
| 105 | 105 | } else { |
| 106 | 106 | |
| 107 | - return Lang::getNumbers( $this->language, $value ) . " " . Lang::get( |
|
| 107 | + return Lang::getNumbers($this->language, $value)." ".Lang::get( |
|
| 108 | 108 | $this->language, |
| 109 | - $config[ $type ][ '*' ] |
|
| 110 | - ) . $time; |
|
| 109 | + $config[$type]['*'] |
|
| 110 | + ).$time; |
|
| 111 | 111 | |
| 112 | 112 | } |
| 113 | 113 | |
@@ -119,12 +119,12 @@ discard block |
||
| 119 | 119 | * @param integer $date date index in ago config file |
| 120 | 120 | * @param string $type duration type on ago config file |
| 121 | 121 | */ |
| 122 | - public function priority( $date, $type ) |
|
| 122 | + public function priority($date, $type) |
|
| 123 | 123 | { |
| 124 | 124 | |
| 125 | - if( $date != 0 ) { |
|
| 125 | + if ($date != 0) { |
|
| 126 | 126 | |
| 127 | - return $this->read( $date, $type ); |
|
| 127 | + return $this->read($date, $type); |
|
| 128 | 128 | |
| 129 | 129 | } else { |
| 130 | 130 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - public function lang( $value ) |
|
| 137 | + public function lang($value) |
|
| 138 | 138 | { |
| 139 | 139 | |
| 140 | 140 | $this->language = $value; |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | 'second' => $this->result->second |
| 161 | 161 | ]; |
| 162 | 162 | |
| 163 | - foreach( $duration as $index => $value ) { |
|
| 163 | + foreach ($duration as $index => $value) { |
|
| 164 | 164 | |
| 165 | - if( $this->priority( $value, $index ) != false ) { |
|
| 165 | + if ($this->priority($value, $index) != false) { |
|
| 166 | 166 | |
| 167 | - return $this->priority( $value, $index ); |
|
| 167 | + return $this->priority($value, $index); |
|
| 168 | 168 | |
| 169 | 169 | } |
| 170 | 170 | |
@@ -7,30 +7,30 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | class DayOf |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * @var object |
|
| 12 | - */ |
|
| 10 | + /** |
|
| 11 | + * @var object |
|
| 12 | + */ |
|
| 13 | 13 | protected $date_time; |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @var array |
|
| 17 | - */ |
|
| 15 | + /** |
|
| 16 | + * @var array |
|
| 17 | + */ |
|
| 18 | 18 | protected $config; |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - protected $calendar_type; |
|
| 20 | + /** |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + protected $calendar_type; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Constructor of DayOf class |
|
| 27 | - */ |
|
| 25 | + /** |
|
| 26 | + * Constructor of DayOf class |
|
| 27 | + */ |
|
| 28 | 28 | public function __construct($date_time, $calendar_type = 'gregorian') |
| 29 | 29 | { |
| 30 | 30 | |
| 31 | - $this->config = include __DIR__.'/CalendarSettings/' . ucfirst($calendar_type) . '.php'; |
|
| 31 | + $this->config = include __DIR__.'/CalendarSettings/' . ucfirst($calendar_type) . '.php'; |
|
| 32 | 32 | |
| 33 | - $this->calendar_type = $calendar_type; |
|
| 33 | + $this->calendar_type = $calendar_type; |
|
| 34 | 34 | |
| 35 | 35 | $this->date_time = $date_time; |
| 36 | 36 | |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * Which day of year is current day. |
|
| 43 | - * |
|
| 44 | - * @since Aug, 03 2015 |
|
| 45 | - * @return integer |
|
| 46 | - */ |
|
| 42 | + * Which day of year is current day. |
|
| 43 | + * |
|
| 44 | + * @since Aug, 03 2015 |
|
| 45 | + * @return integer |
|
| 46 | + */ |
|
| 47 | 47 | public function year() |
| 48 | 48 | { |
| 49 | 49 | |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | - * Which day of week is current day. |
|
| 57 | - * |
|
| 58 | - * @since Aug, 09 2015 |
|
| 59 | - * @return integer |
|
| 60 | - */ |
|
| 56 | + * Which day of week is current day. |
|
| 57 | + * |
|
| 58 | + * @since Aug, 09 2015 |
|
| 59 | + * @return integer |
|
| 60 | + */ |
|
| 61 | 61 | public function week() |
| 62 | 62 | { |
| 63 | 63 | |
@@ -65,47 +65,47 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Return last day of current month |
|
| 70 | - * |
|
| 71 | - * @since Oct, 18 2016 |
|
| 72 | - * @return integer |
|
| 73 | - */ |
|
| 74 | - public function lastDayMonth() { |
|
| 68 | + /** |
|
| 69 | + * Return last day of current month |
|
| 70 | + * |
|
| 71 | + * @since Oct, 18 2016 |
|
| 72 | + * @return integer |
|
| 73 | + */ |
|
| 74 | + public function lastDayMonth() { |
|
| 75 | 75 | |
| 76 | - $days = 0; |
|
| 76 | + $days = 0; |
|
| 77 | 77 | |
| 78 | - switch ( $this->calendar_type ) { |
|
| 78 | + switch ( $this->calendar_type ) { |
|
| 79 | 79 | |
| 80 | - case 'gregorian': |
|
| 80 | + case 'gregorian': |
|
| 81 | 81 | |
| 82 | - if ( intval( $this->date_time->format( 'm' ) ) == 2 && |
|
| 83 | - $this->config[ 'leap_year' ]( $this->date_time->format( 'Y' )) ) |
|
| 84 | - $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ] + 1; |
|
| 85 | - else |
|
| 86 | - $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ]; |
|
| 82 | + if ( intval( $this->date_time->format( 'm' ) ) == 2 && |
|
| 83 | + $this->config[ 'leap_year' ]( $this->date_time->format( 'Y' )) ) |
|
| 84 | + $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ] + 1; |
|
| 85 | + else |
|
| 86 | + $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ]; |
|
| 87 | 87 | |
| 88 | - break; |
|
| 88 | + break; |
|
| 89 | 89 | |
| 90 | - case 'jalali': |
|
| 90 | + case 'jalali': |
|
| 91 | 91 | |
| 92 | - if ( intval( $this->date_time->format( 'm' ) ) == 12 && |
|
| 93 | - $this->config[ 'leap_year' ]( $this->date_time->format( 'Y' )) ) |
|
| 94 | - $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ] + 1; |
|
| 95 | - else |
|
| 96 | - $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ]; |
|
| 92 | + if ( intval( $this->date_time->format( 'm' ) ) == 12 && |
|
| 93 | + $this->config[ 'leap_year' ]( $this->date_time->format( 'Y' )) ) |
|
| 94 | + $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ] + 1; |
|
| 95 | + else |
|
| 96 | + $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ]; |
|
| 97 | 97 | |
| 98 | - break; |
|
| 98 | + break; |
|
| 99 | 99 | |
| 100 | - default: |
|
| 100 | + default: |
|
| 101 | 101 | |
| 102 | - $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ]; |
|
| 102 | + $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ]; |
|
| 103 | 103 | |
| 104 | - break; |
|
| 104 | + break; |
|
| 105 | 105 | |
| 106 | - } |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - return $days; |
|
| 108 | + return $days; |
|
| 109 | 109 | |
| 110 | - } |
|
| 110 | + } |
|
| 111 | 111 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | public function __construct($date_time, $calendar_type = 'gregorian') |
| 29 | 29 | { |
| 30 | 30 | |
| 31 | - $this->config = include __DIR__.'/CalendarSettings/' . ucfirst($calendar_type) . '.php'; |
|
| 31 | + $this->config = include __DIR__.'/CalendarSettings/'.ucfirst($calendar_type).'.php'; |
|
| 32 | 32 | |
| 33 | 33 | $this->calendar_type = $calendar_type; |
| 34 | 34 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | public function year() |
| 48 | 48 | { |
| 49 | 49 | |
| 50 | - return $this->config[ 'day_of_year' ]( $this->date_time ); |
|
| 50 | + return $this->config['day_of_year']($this->date_time); |
|
| 51 | 51 | |
| 52 | 52 | } |
| 53 | 53 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public function week() |
| 62 | 62 | { |
| 63 | 63 | |
| 64 | - return $this->config[ 'day_of_week' ]( $this->date_time ); |
|
| 64 | + return $this->config['day_of_week']($this->date_time); |
|
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | |
@@ -75,31 +75,31 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | $days = 0; |
| 77 | 77 | |
| 78 | - switch ( $this->calendar_type ) { |
|
| 78 | + switch ($this->calendar_type) { |
|
| 79 | 79 | |
| 80 | 80 | case 'gregorian': |
| 81 | 81 | |
| 82 | - if ( intval( $this->date_time->format( 'm' ) ) == 2 && |
|
| 83 | - $this->config[ 'leap_year' ]( $this->date_time->format( 'Y' )) ) |
|
| 84 | - $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ] + 1; |
|
| 82 | + if (intval($this->date_time->format('m')) == 2 && |
|
| 83 | + $this->config['leap_year']($this->date_time->format('Y'))) |
|
| 84 | + $days = $this->config['month_days_number'][intval($this->date_time->format('m'))] + 1; |
|
| 85 | 85 | else |
| 86 | - $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ]; |
|
| 86 | + $days = $this->config['month_days_number'][intval($this->date_time->format('m'))]; |
|
| 87 | 87 | |
| 88 | 88 | break; |
| 89 | 89 | |
| 90 | 90 | case 'jalali': |
| 91 | 91 | |
| 92 | - if ( intval( $this->date_time->format( 'm' ) ) == 12 && |
|
| 93 | - $this->config[ 'leap_year' ]( $this->date_time->format( 'Y' )) ) |
|
| 94 | - $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ] + 1; |
|
| 92 | + if (intval($this->date_time->format('m')) == 12 && |
|
| 93 | + $this->config['leap_year']($this->date_time->format('Y'))) |
|
| 94 | + $days = $this->config['month_days_number'][intval($this->date_time->format('m'))] + 1; |
|
| 95 | 95 | else |
| 96 | - $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ]; |
|
| 96 | + $days = $this->config['month_days_number'][intval($this->date_time->format('m'))]; |
|
| 97 | 97 | |
| 98 | 98 | break; |
| 99 | 99 | |
| 100 | 100 | default: |
| 101 | 101 | |
| 102 | - $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ]; |
|
| 102 | + $days = $this->config['month_days_number'][intval($this->date_time->format('m'))]; |
|
| 103 | 103 | |
| 104 | 104 | break; |
| 105 | 105 | |
@@ -80,20 +80,22 @@ |
||
| 80 | 80 | case 'gregorian': |
| 81 | 81 | |
| 82 | 82 | if ( intval( $this->date_time->format( 'm' ) ) == 2 && |
| 83 | - $this->config[ 'leap_year' ]( $this->date_time->format( 'Y' )) ) |
|
| 84 | - $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ] + 1; |
|
| 85 | - else |
|
| 86 | - $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ]; |
|
| 83 | + $this->config[ 'leap_year' ]( $this->date_time->format( 'Y' )) ) { |
|
| 84 | + $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ] + 1; |
|
| 85 | + } else { |
|
| 86 | + $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ]; |
|
| 87 | + } |
|
| 87 | 88 | |
| 88 | 89 | break; |
| 89 | 90 | |
| 90 | 91 | case 'jalali': |
| 91 | 92 | |
| 92 | 93 | if ( intval( $this->date_time->format( 'm' ) ) == 12 && |
| 93 | - $this->config[ 'leap_year' ]( $this->date_time->format( 'Y' )) ) |
|
| 94 | - $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ] + 1; |
|
| 95 | - else |
|
| 96 | - $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ]; |
|
| 94 | + $this->config[ 'leap_year' ]( $this->date_time->format( 'Y' )) ) { |
|
| 95 | + $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ] + 1; |
|
| 96 | + } else { |
|
| 97 | + $days = $this->config[ 'month_days_number' ][ intval( $this->date_time->format( 'm' ) ) ]; |
|
| 98 | + } |
|
| 97 | 99 | |
| 98 | 100 | break; |
| 99 | 101 | |