diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb index a0e4942..286fff8 100644 --- a/.idea/sonarlint/issuestore/index.pb +++ b/.idea/sonarlint/issuestore/index.pb @@ -242,4 +242,6 @@ E i 9src/Notification/Application/Exception/LogicException.php,0/6/067c6b6951058ddda13ba23de88dd41521bb85c5 e -5src/Shared/Infrastructure/Symfony/ErrorSubscriber.php,b/c/bc0c1c4db90f70046805b7e89628b3be6c2487e0 \ No newline at end of file +5src/Shared/Infrastructure/Symfony/ErrorSubscriber.php,b/c/bc0c1c4db90f70046805b7e89628b3be6c2487e0 +x +Hsrc/Notification/Infrastructure/Doctrine/Exception/NotFoundException.php,a/c/acefa2aa3fc5a6fd4310245260a325bf78b9587c \ No newline at end of file diff --git a/README.md b/README.md index e366aac..001ae5d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ `docker compose build --no-cache` to build fresh images -`docker compose up` - to run application +`docker compose up` to run application Setup application: @@ -53,17 +53,19 @@ I am sorry, no endpoint for fetch, you need to check database ( port 5430 ! ). - you can send notification - you can define several providers for the same type of notification channel - a notification is delayed and later resent if all providers fail ( retry strategy ) +- provided an abstraction between at least two different messaging service providers ( BUT the second is mocker ) - architecture: - DDD ( Notification aggregate ) - Hexagonal - CQRS -- unit and functional tests +- unit and functional tests ## What is not done +- no supervisor to trigger scheduled notifications ( must be run manually ) +- small number of tests :( - bonuses -- there is no second provider, instead there is a mock -## What could be done better +## More time -- add: phpcs, infection, deptrac, more tests +- add: phpcs, infection, deptrac, tests !!! diff --git a/src/Notification/Infrastructure/Doctrine/Exception/NotFoundException.php b/src/Notification/Infrastructure/Doctrine/Exception/NotFoundException.php new file mode 100644 index 0000000..a129b8d --- /dev/null +++ b/src/Notification/Infrastructure/Doctrine/Exception/NotFoundException.php @@ -0,0 +1,10 @@ +find($notificationId) ?: throw new \Exception('Not found'); + return $this->find($notificationId) ?: throw new NotFoundException('Notification not found'); } public function add(Notification $notification): void diff --git a/src/Notification/Infrastructure/Doctrine/Repository/DoctrineProviderConfigurationRepository.php b/src/Notification/Infrastructure/Doctrine/Repository/DoctrineProviderConfigurationRepository.php index ffd9eb0..7251a23 100644 --- a/src/Notification/Infrastructure/Doctrine/Repository/DoctrineProviderConfigurationRepository.php +++ b/src/Notification/Infrastructure/Doctrine/Repository/DoctrineProviderConfigurationRepository.php @@ -8,6 +8,7 @@ use App\Notification\Domain\Provider\Provider; use App\Notification\Domain\Provider\ProviderConfiguration; use App\Notification\Domain\Provider\ProviderConfigurationRepository; +use App\Notification\Infrastructure\Doctrine\Exception\NotFoundException; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; @@ -29,6 +30,6 @@ public function getAvailableProviders(Channel $channel): array public function get(Provider $provider, Channel $channel): ProviderConfiguration { return $this->findOneBy(['provider' => $provider, 'channel' => $channel]) - ?? throw new \Exception('Not found'); + ?? throw new NotFoundException('ProviderConfiguration not found'); } }