@@ -56,7 +56,7 @@ |
||
| 56 | 56 | { |
| 57 | 57 | $json = json_decode($this->body); |
| 58 | 58 | if (json_last_error() !== JSON_ERROR_NONE) { |
| 59 | - throw new \InvalidArgumentException('Failed to decode json:' . json_last_error_msg()); |
|
| 59 | + throw new \InvalidArgumentException('Failed to decode json:'.json_last_error_msg()); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | return $json; |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | $month = IntHelper::parseNullableInt($month); |
| 132 | 132 | $year = IntHelper::parseNullableInt($year); |
| 133 | 133 | |
| 134 | - $month = $month ?: (int)date('m') + (intval(date('d')) >= 20 ? 1 : 0); |
|
| 135 | - $year = $year ?: (int)date('Y'); |
|
| 134 | + $month = $month ?: (int) date('m') + (intval(date('d')) >= 20 ? 1 : 0); |
|
| 135 | + $year = $year ?: (int) date('Y'); |
|
| 136 | 136 | |
| 137 | 137 | return $this->getPunchesFromPage($this->getPunchesPage($month, $year)); |
| 138 | 138 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | } |
| 162 | 162 | $punches = $this->getPunches($month, $year); |
| 163 | 163 | |
| 164 | - return array_filter($punches['punches'], function (\DateTime $punchDateTime) use ($day) { |
|
| 164 | + return array_filter($punches['punches'], function(\DateTime $punchDateTime) use ($day) { |
|
| 165 | 165 | return (int) $punchDateTime->format('d') === (int) $day; |
| 166 | 166 | }); |
| 167 | 167 | } |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | private function getPunchesFromPage(IHttpResponse $punchesPageResponse) |
| 360 | 360 | { |
| 361 | 361 | if ($punchesPageResponse->getHttpStatus() !== IHttpClient::HTTP_STATUS_OK) { |
| 362 | - throw new InvalidArgumentException('The request returned http status ' . $punchesPageResponse->getHttpStatus()); |
|
| 362 | + throw new InvalidArgumentException('The request returned http status '.$punchesPageResponse->getHttpStatus()); |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | $punches = $this->parsePunchesPage($punchesPageResponse); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | /** |
| 212 | 212 | * Gets the user data and punches. |
| 213 | 213 | * |
| 214 | - * @param null $field |
|
| 214 | + * @param string $field |
|
| 215 | 215 | * |
| 216 | 216 | * @return mixed |
| 217 | 217 | */ |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | /** |
| 228 | 228 | * Gets all the data and punches. Cached method. |
| 229 | 229 | * |
| 230 | - * @return mixed |
|
| 230 | + * @return \PHPUnit_Framework_MockObject_Matcher_InvokedCount |
|
| 231 | 231 | */ |
| 232 | 232 | private function getData() { |
| 233 | 233 | return once(function () { |
@@ -247,6 +247,9 @@ discard block |
||
| 247 | 247 | }); |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | + /** |
|
| 251 | + * @param string $endpoint |
|
| 252 | + */ |
|
| 250 | 253 | private function buildUrl($endpoint, array $params = []) { |
| 251 | 254 | return once(function () use ($endpoint, $params) { |
| 252 | 255 | return vsprintf($endpoint, array_merge([static::API_BASE_URL], $params)); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | $punches = $this->getPunches($month, $year); |
| 178 | 178 | |
| 179 | - return array_filter($punches['punches'], function (\DateTime $punchDateTime) use ($day) { |
|
| 179 | + return array_filter($punches['punches'], function(\DateTime $punchDateTime) use ($day) { |
|
| 180 | 180 | return (int) $punchDateTime->format('d') === (int) $day; |
| 181 | 181 | }); |
| 182 | 182 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @return mixed |
| 234 | 234 | */ |
| 235 | 235 | private function getData() { |
| 236 | - return once(function () { |
|
| 236 | + return once(function() { |
|
| 237 | 237 | $params = [ |
| 238 | 238 | 'company' => $this->companyId, |
| 239 | 239 | 'matricula' => $this->username, |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | private function buildUrl($endpoint, array $params = []) { |
| 254 | - return once(function () use ($endpoint, $params) { |
|
| 254 | + return once(function() use ($endpoint, $params) { |
|
| 255 | 255 | return vsprintf($endpoint, array_merge([static::API_BASE_URL], $params)); |
| 256 | 256 | }); |
| 257 | 257 | } |
@@ -277,10 +277,10 @@ discard block |
||
| 277 | 277 | |
| 278 | 278 | foreach ($dias as $dia => $dadosDia) { |
| 279 | 279 | // Parse falta |
| 280 | - $falta = array_filter($dadosDia->resultado, function ($item) { return $item->tipo == 'FALTA'; }); |
|
| 280 | + $falta = array_filter($dadosDia->resultado, function($item) { return $item->tipo == 'FALTA'; }); |
|
| 281 | 281 | |
| 282 | 282 | // Parse extra |
| 283 | - $extra = array_filter($dadosDia->resultado, function ($item) { return $item->tipo == 'Extra'; }); |
|
| 283 | + $extra = array_filter($dadosDia->resultado, function($item) { return $item->tipo == 'Extra'; }); |
|
| 284 | 284 | |
| 285 | 285 | $tmp[$dia][] = [ |
| 286 | 286 | 'falta' => empty($falta) ? '00:00' : preg_replace('/^(-)?(\d{2})(\d{2})$/i', '\1\2:\3', array_shift($falta)->valor), |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | */ |
| 90 | 90 | public function post($url, $data = [], array $config = []) |
| 91 | 91 | { |
| 92 | - return once(function () use ($url, $data, $config) { |
|
| 92 | + return once(function() use ($url, $data, $config) { |
|
| 93 | 93 | return $this->request(IHttpClient::HTTP_POST, $url, $data, $config); |
| 94 | 94 | }); |
| 95 | 95 | } |