Skip to content

Commit

Permalink
refactored PR for small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lung committed Apr 19, 2024
1 parent e9289cd commit a02d4cc
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 27 deletions.
8 changes: 1 addition & 7 deletions src/Import/ImportSrs.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,23 @@
use kissj\Event\Event;
use kissj\Event\EventType\Obrok\EventTypeObrok;
use kissj\FlashMessages\FlashMessagesInterface;
use kissj\Participant\Ist\Ist;
use kissj\Participant\Ist\IstRepository;
use kissj\Participant\Ist\IstService;
use kissj\Participant\Participant;
use kissj\Participant\ParticipantRepository;
use kissj\Participant\ParticipantRole;
use kissj\Payment\PaymentService;
use kissj\Payment\PaymentStatus;
use kissj\User\User;
use kissj\User\UserRepository;
use kissj\User\UserRole;
use kissj\User\UserService;
use kissj\User\UserStatus;
use League\Csv\Exception as LeagueCsvException;
use LeanMapper\Exception\InvalidStateException;
use setasign\Fpdi\PdfParser\Type\PdfNull;
use Slim\Psr7\UploadedFile;
use Symfony\Contracts\Translation\TranslatorInterface;

readonly class ImportSrs
{


public function __construct(
private IstService $istService,
private IstRepository $istRepository,
Expand Down Expand Up @@ -69,7 +63,7 @@ public function importIst(UploadedFile $istsDataFile, Event $event): void
fn (string $value): string => substr($value, 1, -1),
$istData,
);
if ($this->istRepository->isIstExisting($istData['E-mail'], $event)) {
if ($this->istRepository->isIstExisting($istData['E-mail'], $event)) {
$existingCount++;
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Participant/Admin/AdminService.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private function handlePayments(
}

$correctPayment->participant = $participantTo;
$this->paymentRepository-> persist($correctPayment);
$this->paymentRepository->persist($correctPayment);

return $correctPayment;
}
Expand Down
10 changes: 3 additions & 7 deletions src/Participant/Ist/IstRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@

namespace kissj\Participant\Ist;

use DateTimeImmutable;
use Dibi\Row;
use kissj\Event\Event;
use kissj\Orm\Order;
use kissj\Orm\Repository;
use kissj\Participant\Participant;
use kissj\Participant\ParticipantRole;
use kissj\Payment\Payment;
use kissj\Payment\PaymentStatus;

/**
* @table participant
Expand All @@ -29,13 +25,13 @@ public function isIstExisting(string $email, Event $event): bool
$qb = $this->createFluent();

$qb->where('participant.email = %s', $email);
$qb->where('participant.role = ist');
$qb->where('participant.role = %s', ParticipantRole::Ist);
$qb->join('user')->as('u')->on('u.id = participant.user_id');
$qb->where('u.event_id = %i', $event->id);

/** @var ?Row $row */
$row = $qb->fetch();

return $row instanceof Row;
}
return $row instanceof Row;
}
}
7 changes: 3 additions & 4 deletions src/Participant/Ist/IstService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

namespace kissj\Participant\Ist;

use DateTimeImmutable;
use kissj\Event\Event;
use kissj\Participant\Participant;
Expand All @@ -13,10 +14,8 @@
use kissj\Payment\PaymentStatus;
use kissj\User\User;


readonly class IstService
{

public function __construct(
private ParticipantRepository $participantRepository,
private PaymentRepository $paymentRepository,
Expand All @@ -26,7 +25,7 @@ public function __construct(
/**
* @param array<string> $preferredPosition
*/
public function createIstPayment (
public function createIstPayment(
User $user,
Event $event,
string $contingent,
Expand Down Expand Up @@ -102,4 +101,4 @@ public function createIstPayment (

return $participant;
}
}
}
2 changes: 1 addition & 1 deletion src/Participant/ParticipantRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public function findOneByEntryCode(string $entryCode): ?Participant
{
return $this->findOneBy(['entry_code' => $entryCode]);
}

public function findParticipantFromId(int $participantId, Event $event): ?Participant
{
$qb = $this->connection->select('participant.*')->from($this->getTable());
Expand Down
6 changes: 0 additions & 6 deletions src/User/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@

namespace kissj\User;

use DateTimeImmutable;
use kissj\Application\DateTimeUtils;
use kissj\Event\Event;
use kissj\Mailer\Mailer;
use kissj\Participant\Participant;
use kissj\Participant\ParticipantRepository;
use kissj\Participant\ParticipantRole;
use kissj\Payment\Payment;
use kissj\Payment\PaymentRepository;
use kissj\Payment\PaymentStatus;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Routing\RouteContext;

Expand Down Expand Up @@ -133,7 +129,6 @@ public function createParticipantSetRole(User $user, string $role): Participant
return $participant;
}


public function createSkautisUser(
Event $event,
int $skautisId,
Expand All @@ -151,7 +146,6 @@ public function createSkautisUser(

$this->userRepository->persist($user);


return $user;
}

Expand Down
1 change: 0 additions & 1 deletion tests/Unit/Payment/PaymentServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public function testGenerateVariableNumber(): void
Mockery::mock(LoginTokenRepository::class),
Mockery::mock(ParticipantRepository::class),
Mockery::mock(UserRepository::class),
Mockery::mock(PaymentRepository::class),
$mailerMock,
),
Mockery::mock(FlashMessagesBySession::class),
Expand Down

0 comments on commit a02d4cc

Please sign in to comment.