Skip to content

Commit

Permalink
Фикс получения расписания работы ОПС
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaoda committed Oct 30, 2019
1 parent 399e0cf commit 27510fb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"ext-json": "*",
"ext-soap": "*",
"guzzlehttp/guzzle": "^6.3",
"psr/log": "^1.1"
"psr/log": "^1.1",
"ext-intl": "*"
},
"require-dev": {
"illuminate/support": "5.1 - 5.8",
Expand Down
5 changes: 2 additions & 3 deletions src/Dispatching/Endpoints/PostOffices/Responses/Lunch.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
final class Lunch implements Arrayable
{
use DataAware;

use TimeIntervalAware;

private function getBeginValue()
protected function getBeginValue()
{
return $this->get('begin-lunchtime');
}

private function getEndValue()
protected function getEndValue()
{
return $this->get('end-lunchtime');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public function getEnd(): ?string
return $this->humanizeTime($this->getEndValue());
}

private function humanizeTime(string $time): ?string
private function humanizeTime(?string $time): ?string
{
if ($this === null) {
if ($time === null) {
return null;
}

Expand Down
21 changes: 18 additions & 3 deletions src/Dispatching/Endpoints/PostOffices/Responses/WorkingHours.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,22 @@ final class WorkingHours implements Arrayable

public function getDayNumber(): ?int
{
return $this->get('weekday-id');
return $this->get('weekday-id', 'int');
}

public function getDayName(?string $locale = null): ?string
{
if (null === $this->getDayNumber()) {
return null;
}

if ($this->get('weekday-name')) {
return $this->get('weekday-name');
}

return (new \IntlDateFormatter(
$locale ?? 'ru_RU', \IntlDateFormatter::NONE, \IntlDateFormatter::NONE, null, null, 'EEEE'
))->format(\strtotime("next Sunday + {$this->getDayNumber()} days"));
}

/**
Expand All @@ -36,12 +51,12 @@ public function getLunches()
return Instantiator::instantiate(new ArrayOf(Lunch::class), $this->get('lunches'));
}

private function getBeginValue()
protected function getBeginValue()
{
return $this->get('begin-worktime');
}

private function getEndValue()
protected function getEndValue()
{
return $this->get('end-worktime');
}
Expand Down

0 comments on commit 27510fb

Please sign in to comment.