-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from answear/opening-time
Add OpeningSchedule and OpeningTime for Office
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Answear\SpeedyBundle\Response\Struct; | ||
|
||
use Webmozart\Assert\Assert; | ||
|
||
class OpeningSchedule | ||
{ | ||
public OpeningTime $weekday; | ||
public OpeningTime $saturday; | ||
public OpeningTime $sunday; | ||
|
||
public function __construct(OpeningTime $weekday, OpeningTime $saturday, OpeningTime $sunday) | ||
{ | ||
$this->weekday = $weekday; | ||
$this->saturday = $saturday; | ||
$this->sunday = $sunday; | ||
} | ||
|
||
public static function fromArray(array $officeData): self | ||
{ | ||
Assert::stringNotEmpty($officeData['workingTimeFrom']); | ||
Assert::stringNotEmpty($officeData['workingTimeTo']); | ||
Assert::stringNotEmpty($officeData['workingTimeHalfFrom']); | ||
Assert::stringNotEmpty($officeData['workingTimeHalfTo']); | ||
Assert::stringNotEmpty($officeData['workingTimeDayOffFrom']); | ||
Assert::stringNotEmpty($officeData['workingTimeDayOffTo']); | ||
|
||
return new self( | ||
new OpeningTime($officeData['workingTimeFrom'], $officeData['workingTimeTo']), | ||
new OpeningTime($officeData['workingTimeHalfFrom'], $officeData['workingTimeHalfTo']), | ||
new OpeningTime($officeData['workingTimeDayOffFrom'], $officeData['workingTimeDayOffTo']) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Answear\SpeedyBundle\Response\Struct; | ||
|
||
class OpeningTime | ||
{ | ||
public string $from; | ||
public string $to; | ||
|
||
public function __construct(string $from, string $to) | ||
{ | ||
$this->from = $from; | ||
$this->to = $to; | ||
} | ||
|
||
public function isClosed(): bool | ||
{ | ||
return '00:00' === $this->from && '00:00' === $this->to; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters