Skip to content

BRAIN-23 - Added turnover reporting #17

BRAIN-23 - Added turnover reporting

BRAIN-23 - Added turnover reporting #17

Triggered via pull request January 19, 2024 12:19
Status Success
Total duration 48s
Artifacts

php.yml

on: pull_request
Fit to window
Zoom out
Zoom in

Annotations

5 warnings
infection: src/Braintree/Util/ReportService.php#L21
Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ use Symfony\Component\DependencyInjection\Attribute\Autowire; class ReportService { - public function __construct(#[Autowire(env: 'REPORT_IDENTIFIER')] private readonly string $apiIdentifier, private readonly EntityManagerInterface $em, private readonly TransactionReportRepository $transactionReportRepository, private readonly Client $client = new Client(['base_uri' => 'https://api.shopware.com'])) + public function __construct(#[Autowire(env: 'REPORT_IDENTIFIER')] private readonly string $apiIdentifier, private readonly EntityManagerInterface $em, private readonly TransactionReportRepository $transactionReportRepository, private readonly Client $client = new Client([])) { } /**
infection: src/Braintree/Util/ReportService.php#L35
Escaped Mutant for Mutator "CastFloat": --- Original +++ New @@ @@ $reports = []; foreach ($transactions as $transaction) { $reports[$transaction->getCurrencyIso()] ??= 0; - $reports[$transaction->getCurrencyIso()] += (float) $transaction->getTotalPrice(); + $reports[$transaction->getCurrencyIso()] += $transaction->getTotalPrice(); } $requests = []; foreach ($reports as $currency => $turnover) {
infection: src/Braintree/Util/ReportService.php#L40
Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ } $requests = []; foreach ($reports as $currency => $turnover) { - $body = ['identifier' => $this->apiIdentifier, 'reportDate' => (new \DateTime())->format(\DateTimeInterface::ATOM), 'reportDataKeys' => ['turnover' => $turnover], 'currency' => $currency]; + $body = ['reportDate' => (new \DateTime())->format(\DateTimeInterface::ATOM), 'reportDataKeys' => ['turnover' => $turnover], 'currency' => $currency]; $requests[$currency] = $this->client->postAsync('/shopwarepartners/reports/technology', [RequestOptions::JSON => $body]); } $rejectedCurrencies = [];
infection: src/Braintree/Util/ReportService.php#L57
Escaped Mutant for Mutator "Continue_": --- Original +++ New @@ @@ /** @var array{state: string, reason: ClientException} $response */ foreach (Utils::settle($requests)->wait() as $currency => $response) { if ($response['state'] !== Promise::REJECTED) { - continue; + break; } // @todo - Implement logging // $this->logger->warning(\sprintf(
infection: src/Braintree/Util/ReportService.php#L81
Escaped Mutant for Mutator "ArrayOneItem": --- Original +++ New @@ @@ $this->em->remove($transaction); } $this->em->flush(); - return $rejectedCurrencies; + return count($rejectedCurrencies) > 1 ? array_slice($rejectedCurrencies, 0, 1, true) : $rejectedCurrencies; } }