Skip to content

Commit

Permalink
DON-998 - fix psalm:
Browse files Browse the repository at this point in the history
* remove 'missing salesforceId' exeptions, it will never be null
  • Loading branch information
Dorota Hawro committed Jan 3, 2025
1 parent 805e582 commit 913327a
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 15 deletions.
1 change: 0 additions & 1 deletion integrationTests/PullCharityUpdatedBasedOnSfHookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function testItPullsCharityUpdateAfterSalesforceSendsHook(): void
$campaign = TestCase::someCampaign();
$charity = $campaign->getCharity();
$sfId = $charity->getSalesforceId();
\assert(is_string($sfId));

$em->persist($campaign);
$em->persist($charity);
Expand Down
4 changes: 1 addition & 3 deletions src/Application/Commands/SetupTestMandate.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in
$donorId,
Money::fromPoundsGBP($amount),
Salesforce18Id::ofCampaign($campaign->getSalesforceId()),
Salesforce18Id::ofCharity(
$charity->getSalesforceId() ?? throw new \Exception('Missing charity sf ID')
),
Salesforce18Id::ofCharity($charity->getSalesforceId()),
(bool)$input->getOption('gift-aid'),
$dayOfMonth
);
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/DonationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function () use ($donation) {
if ($stripeAccountId === null || $stripeAccountId === '') {
$this->logger->error(sprintf(
'Stripe Payment Intent create error: Stripe Account ID not set for Account %s',
$campaign->getCharity()->getSalesforceId() ?? 'missing charity sf ID',
$campaign->getCharity()->getSalesforceId(),
));
throw new StripeAccountIdNotSetForAccount();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Domain/RegularGivingMandateRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ private function getMandatesWithCharities(\Doctrine\ORM\Query $query)
$charities = [];
foreach ($x as $entity) {
if ($entity instanceof Charity) {
$salesforceId = $entity->getSalesforceId();
\assert($salesforceId !== null);

$charities[$salesforceId] = $entity;
$charities[$entity->getSalesforceId()] = $entity;
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/Domain/RegularGivingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ public function setupNewMandate(
);
}

$charityId = Salesforce18Id::ofCharity(
$campaign->getCharity()->getSalesforceId() ?? throw new \Exception('missing charity SF ID')
);
$charityId = Salesforce18Id::ofCharity($campaign->getCharity()->getSalesforceId());

/**
* For now we assume this exists - @todo-regular-giving ensure that for all accounts (or all accounts that
Expand Down
4 changes: 1 addition & 3 deletions tests/Domain/RegularGivingMandateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ public function testItRendersApiModel(): void
donationAmount: Money::fromPoundsGBP(500),
dayOfMonth: DayOfMonth::of(12),
campaignId: Salesforce18Id::ofCampaign('campaign9012345678'),
charityId: Salesforce18Id::ofCharity(
$charity->getSalesforceId() ?? throw new \Exception("sf id can't be null")
),
charityId: Salesforce18Id::ofCharity($charity->getSalesforceId()),
giftAid: true,
);

Expand Down

0 comments on commit 913327a

Please sign in to comment.