| 1: | <?php declare(strict_types=1); |
| 2: | |
| 3: | namespace Salient\Core\Provider; |
| 4: | |
| 5: | use Salient\Contract\Container\ContainerInterface; |
| 6: | use Salient\Contract\Core\Provider\ProviderContextInterface; |
| 7: | use Salient\Contract\Core\Provider\ProviderInterface; |
| 8: | use Salient\Contract\Core\DateFormatterInterface; |
| 9: | use Salient\Core\Date\DateFormatter; |
| 10: | use Salient\Core\Exception\MethodNotImplementedException; |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | abstract class AbstractProvider implements ProviderInterface |
| 18: | { |
| 19: | protected ContainerInterface $App; |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | public function __construct(ContainerInterface $app) |
| 25: | { |
| 26: | $this->App = $app; |
| 27: | } |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | final public function getContainer(): ContainerInterface |
| 33: | { |
| 34: | return $this->App; |
| 35: | } |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | public function getDateFormatter(): DateFormatterInterface |
| 41: | { |
| 42: | return new DateFormatter(); |
| 43: | } |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | public function getContext(): ProviderContextInterface |
| 49: | { |
| 50: | |
| 51: | return new ProviderContext($this, $this->App); |
| 52: | } |
| 53: | |
| 54: | |
| 55: | |
| 56: | |
| 57: | public function checkHeartbeat(int $ttl = 300) |
| 58: | { |
| 59: | throw new MethodNotImplementedException( |
| 60: | static::class, |
| 61: | __FUNCTION__, |
| 62: | ProviderInterface::class, |
| 63: | ); |
| 64: | } |
| 65: | |
| 66: | |
| 67: | final protected function createDateFormatter(): void {} |
| 68: | } |
| 69: | |