-
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 #23 from wmde/fun-cs
Add new Coding Style
- Loading branch information
Showing
24 changed files
with
58 additions
and
210 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
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 |
---|---|---|
|
@@ -12,12 +12,12 @@ | |
use WMDE\Fundraising\SubscriptionContext\Domain\Repositories\SubscriptionRepositoryException; | ||
|
||
/** | ||
* @license GNU GPL v2+ | ||
* @license GPL-2.0-or-later | ||
* @author Gabriel Birke < [email protected] > | ||
*/ | ||
class DoctrineSubscriptionRepository implements SubscriptionRepository { | ||
|
||
private $entityManager; | ||
private EntityManager $entityManager; | ||
|
||
public function __construct( EntityManager $entityManager ) { | ||
$this->entityManager = $entityManager; | ||
|
@@ -47,15 +47,21 @@ public function countSimilar( Subscription $subscription, \DateTime $cutoffDateT | |
->setParameter( 'cutoffDate', $cutoffDateTime, Type::DATETIME ) | ||
->getQuery(); | ||
try { | ||
return (int) $query->getSingleScalarResult(); | ||
return (int)$query->getSingleScalarResult(); | ||
} | ||
catch ( ORMException $e ) { | ||
throw new SubscriptionRepositoryException( 'Could not count subscriptions, check your query and its parameters.', $e ); | ||
} | ||
|
||
} | ||
|
||
/** | ||
*/ | ||
|
||
/** | ||
* @param string $confirmationCode | ||
* | ||
* @return Subscription|null | ||
* | ||
* @throws SubscriptionRepositoryException | ||
*/ | ||
public function findByConfirmationCode( string $confirmationCode ): ?Subscription { | ||
|
@@ -69,4 +75,4 @@ public function findByConfirmationCode( string $confirmationCode ): ?Subscriptio | |
} | ||
} | ||
|
||
} | ||
} |
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
use WMDE\Fundraising\SubscriptionContext\Domain\Model\Subscription; | ||
|
||
/** | ||
* @license GNU GPL v2+ | ||
* @license GPL-2.0-or-later | ||
* @author Gabriel Birke < [email protected] > | ||
*/ | ||
interface SubscriptionRepository { | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
namespace WMDE\Fundraising\SubscriptionContext\Domain\Repositories; | ||
|
||
/** | ||
* @license GNU GPL v2+ | ||
* @license GPL-2.0-or-later | ||
* @author Gabriel Birke < [email protected] > | ||
*/ | ||
class SubscriptionRepositoryException extends \RuntimeException { | ||
|
@@ -14,4 +14,4 @@ public function __construct( string $message, \Exception $previous = null ) { | |
parent::__construct( $message, 0, $previous ); | ||
} | ||
|
||
} | ||
} |
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 |
---|---|---|
|
@@ -11,16 +11,16 @@ | |
use WMDE\Fundraising\SubscriptionContext\Domain\Repositories\SubscriptionRepositoryException; | ||
|
||
/** | ||
* @license GNU GPL v2+ | ||
* @license GPL-2.0-or-later | ||
* @author Jeroen De Dauw < [email protected] > | ||
*/ | ||
class LoggingSubscriptionRepository implements SubscriptionRepository { | ||
|
||
const CONTEXT_EXCEPTION_KEY = 'exception'; | ||
private const CONTEXT_EXCEPTION_KEY = 'exception'; | ||
|
||
private $repository; | ||
private $logger; | ||
private $logLevel; | ||
private SubscriptionRepository $repository; | ||
private LoggerInterface $logger; | ||
private string $logLevel; | ||
|
||
public function __construct( SubscriptionRepository $repository, LoggerInterface $logger ) { | ||
$this->repository = $repository; | ||
|
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 |
---|---|---|
|
@@ -33,4 +33,4 @@ public function newEventSubscribers(): array { | |
]; | ||
} | ||
|
||
} | ||
} |
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 |
---|---|---|
|
@@ -6,14 +6,14 @@ | |
|
||
use WMDE\EmailAddress\EmailAddress; | ||
use WMDE\Fundraising\SubscriptionContext\Domain\Model\Subscription; | ||
use WMDE\Fundraising\SubscriptionContext\Infrastructure\TemplateMailerInterface; | ||
use WMDE\Fundraising\SubscriptionContext\Domain\Repositories\SubscriptionRepository; | ||
use WMDE\Fundraising\SubscriptionContext\Domain\Repositories\SubscriptionRepositoryException; | ||
use WMDE\Fundraising\SubscriptionContext\Infrastructure\TemplateMailerInterface; | ||
use WMDE\Fundraising\SubscriptionContext\Validation\SubscriptionValidator; | ||
use WMDE\FunValidators\ValidationResponse; | ||
|
||
/** | ||
* @license GNU GPL v2+ | ||
* @license GPL-2.0-or-later | ||
* @author Gabriel Birke < [email protected] > | ||
*/ | ||
class AddSubscriptionUseCase { | ||
|
@@ -26,7 +26,6 @@ class AddSubscriptionUseCase { | |
|
||
public function __construct( SubscriptionRepository $subscriptionRepository, | ||
SubscriptionValidator $subscriptionValidator, TemplateMailerInterface $mailer ) { | ||
|
||
$this->subscriptionRepository = $subscriptionRepository; | ||
$this->subscriptionValidator = $subscriptionValidator; | ||
$this->mailer = $mailer; | ||
|
@@ -80,4 +79,4 @@ private function generateConfirmationCode(): string { | |
return bin2hex( random_bytes( self::CONFIRMATION_CODE_LENGTH_BYTES ) ); | ||
} | ||
|
||
} | ||
} |
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
namespace WMDE\Fundraising\SubscriptionContext\UseCases\AddSubscription; | ||
|
||
/** | ||
* @license GNU GPL v2+ | ||
* @license GPL-2.0-or-later | ||
* @author Gabriel Birke < [email protected] > | ||
*/ | ||
class SubscriptionRequest { | ||
|
@@ -38,4 +38,4 @@ public function setSource( string $source ): void { | |
$this->source = $source; | ||
} | ||
|
||
} | ||
} |
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 |
---|---|---|
|
@@ -5,13 +5,13 @@ | |
namespace WMDE\Fundraising\SubscriptionContext\UseCases\ConfirmSubscription; | ||
|
||
use WMDE\EmailAddress\EmailAddress; | ||
use WMDE\Fundraising\SubscriptionContext\Infrastructure\TemplateMailerInterface; | ||
use WMDE\Fundraising\SubscriptionContext\Domain\Repositories\SubscriptionRepository; | ||
use WMDE\Fundraising\SubscriptionContext\Infrastructure\TemplateMailerInterface; | ||
use WMDE\FunValidators\ConstraintViolation; | ||
use WMDE\FunValidators\ValidationResponse; | ||
|
||
/** | ||
* @license GNU GPL v2+ | ||
* @license GPL-2.0-or-later | ||
* @author Gabriel Birke < [email protected] > | ||
*/ | ||
class ConfirmSubscriptionUseCase { | ||
|
@@ -26,7 +26,6 @@ public function __construct( SubscriptionRepository $subscriptionRepository, Tem | |
} | ||
|
||
public function confirmSubscription( string $confirmationCode ): ValidationResponse { | ||
|
||
$subscription = $this->subscriptionRepository->findByConfirmationCode( $confirmationCode ); | ||
|
||
if ( $subscription === null ) { | ||
|
@@ -47,4 +46,4 @@ public function confirmSubscription( string $confirmationCode ): ValidationRespo | |
] ); | ||
} | ||
|
||
} | ||
} |
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 |
---|---|---|
|
@@ -11,15 +11,15 @@ | |
use WMDE\FunValidators\ValidationResult; | ||
|
||
/** | ||
* @license GNU GPL v2+ | ||
* @license GPL-2.0-or-later | ||
* @author Gabriel Birke < [email protected] > | ||
*/ | ||
class SubscriptionDuplicateValidator { | ||
|
||
const SOURCE_NAME = 'subscription_duplicate_subscription'; | ||
public const SOURCE_NAME = 'subscription_duplicate_subscription'; | ||
|
||
private $repository; | ||
private $cutoffDateTime; | ||
private SubscriptionRepository $repository; | ||
private \DateTime $cutoffDateTime; | ||
|
||
public function __construct( SubscriptionRepository $repository, \DateTime $cutoffDateTime ) { | ||
$this->repository = $repository; | ||
|
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
use WMDE\FunValidators\Validators\RequiredFieldValidator; | ||
|
||
/** | ||
* @license GNU GPL v2+ | ||
* @license GPL-2.0-or-later | ||
* @author Gabriel Birke < [email protected] > | ||
*/ | ||
class SubscriptionValidator { | ||
|
@@ -49,4 +49,4 @@ private function getRequiredFieldViolations( Subscription $subscription ): array | |
]; | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.