Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStorz committed Sep 11, 2024
1 parent a22c9af commit dcd889d
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 44 deletions.
9 changes: 5 additions & 4 deletions src/Command/ImportGamificationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

class ImportGamificationCommand extends StatisticsCommand
{

/** @var EntityManagerInterface $em */
private EntityManagerInterface $em;

Expand Down Expand Up @@ -45,7 +44,7 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output): int
{
$start = microtime( true);
$start = microtime(true);
$json = json_decode(file_get_contents($this->pathToJson), true);

$this->em->getConnection()->executeQuery('DELETE FROM gamification_person_profile');
Expand All @@ -68,7 +67,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

protected function importLevels(array $jsonLevels, OutputInterface $output) {
protected function importLevels(array $jsonLevels, OutputInterface $output)
{
foreach ($jsonLevels as $jsonLevel) {
$level = $this->levelRepository->findOneBy(["key" => $jsonLevel["key"]]);
if (is_null($level)) {
Expand All @@ -90,7 +90,8 @@ protected function importLevels(array $jsonLevels, OutputInterface $output) {
$this->em->flush();
}

protected function importGoals(array $jsonGoals, OutputInterface $output) {
protected function importGoals(array $jsonGoals, OutputInterface $output)
{
foreach ($jsonGoals as $jsonGoal) {
$goal = $this->goalRepository->findOneBy(['key' => $jsonGoal['key']]);
if (is_null($goal)) {
Expand Down
7 changes: 4 additions & 3 deletions src/Command/PseudonymizeLoginCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

class PseudonymizeLoginCommand extends StatisticsCommand
{

private LoginRepository $loginRepository;

private float $duration;
Expand All @@ -34,8 +33,10 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output): int
{
$start = microtime( true);
$pseudonymizedLogins = $this->loginRepository->pseudonymizeAllOlderThan18Months(function ($personId) { return hash('sha256', $personId);}); // sha256 is mostly collision free and currently irreversible, sufficient for our purposes.
$start = microtime(true);
$pseudonymizedLogins = $this->loginRepository->pseudonymizeAllOlderThan18Months(function ($personId) {
return hash('sha256', $personId);
}); // sha256 is mostly collision free and currently irreversible, sufficient for our purposes.
$log = $input->getOption('log');
if ($log) {
$output->writeln('Following Logins (id) have been pseudonymized:');
Expand Down
16 changes: 7 additions & 9 deletions src/Controller/Api/GamificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,31 @@ public function postGroupChange(
public function usedCardLayer(
Request $request,
PersonGamificationService $personGamificationService
)
{
) {
$personGamificationService->genericGoalProgress($this->getUser(), 'card');
return new Response('', 200);
}

public function usedDataFilter(
Request $request,
PersonGamificationService $personGamificationService
)
{
) {
$personGamificationService->genericGoalProgress($this->getUser(), 'data');
return new Response('', 200);
}

public function usedTimeFilter(
Request $request,
PersonGamificationService $personGamificationService
)
{
) {
$personGamificationService->genericGoalProgress($this->getUser(), 'time');
return new Response('', 200);
}

public function getUserProfile(Request $request,
PersonGamificationService $personGamificationService)
{
public function getUserProfile(
Request $request,
PersonGamificationService $personGamificationService
) {
$dto = $personGamificationService->getPersonGamificationDTO($this->getUser(), $request->getLocale());
return $this->json($dto);
}
Expand Down
4 changes: 2 additions & 2 deletions src/DTO/Mapper/GamificationPersonProfileMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class GamificationPersonProfileMapper
{

public static function createFromEntity(GamificationPersonProfile $profile, string $locale): PersonGamificationDTO
{
$dto = new PersonGamificationDTO();
Expand All @@ -27,7 +26,8 @@ public static function createFromEntity(GamificationPersonProfile $profile, stri
return $dto;
}

public static function checkLevelUp(GamificationPersonProfile $profile) {
public static function checkLevelUp(GamificationPersonProfile $profile)
{
$levelUps = $profile->getPerson()->getLevelUps();
if (count($levelUps) > 0) {
return true;
Expand Down
1 change: 0 additions & 1 deletion src/DTO/Model/Gamification/GoalDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,4 @@ public function setRequired(bool $required): void
{
$this->required = $required;
}

}
1 change: 0 additions & 1 deletion src/DTO/Model/Gamification/LevelDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,4 @@ public function setGoals(array $goals): void
{
$this->goals = $goals;
}

}
1 change: 0 additions & 1 deletion src/DTO/Model/Gamification/PersonGamificationDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,4 @@ public function setLevels(array $levels): void
{
$this->levels = $levels;
}

}
2 changes: 1 addition & 1 deletion src/Entity/Gamification/GamificationPersonProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class GamificationPersonProfile
* @ORM\Column(type="boolean")
*/
private $el_improved;


public function getId(): ?int
{
Expand Down
2 changes: 0 additions & 2 deletions src/Entity/Gamification/Level.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,4 @@ public function setKey($key): void
{
$this->key = $key;
}


}
5 changes: 3 additions & 2 deletions src/Repository/Gamification/LoginRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ public function __construct(ManagerRegistry $registry)
parent::__construct($registry, Login::class);
}

public function findAllActiveBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) {
public function findAllActiveBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
{
$criteria['hashed_id'] = null;
return $this->findBy($criteria,$orderBy, $limit, $offset);
return $this->findBy($criteria, $orderBy, $limit, $offset);
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/Repository/Security/PermissionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,4 @@ public function endAllOpenPermissions(): void
]
);
}


}
9 changes: 5 additions & 4 deletions src/Service/Gamification/LoginService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public function __construct(
LoginRepository $loginRepository,
GroupRepository $groupRepository,
PermissionRepository $permissionRepository
)
{
) {
$this->personRepository = $personRepository;
$this->loginRepository = $loginRepository;
$this->groupRepository = $groupRepository;
$this->permissionRepository = $permissionRepository;
}

public function logByUserDTOForLogin(PbsUserDTO $userDTO):Login {
public function logByUserDTOForLogin(PbsUserDTO $userDTO): Login
{
$login = new Login();

$activeGroupDTO = $userDTO->getGroups()[0]; // Group 0 is the active group on Login.
Expand Down Expand Up @@ -63,7 +63,8 @@ public function logByUserDTOForLogin(PbsUserDTO $userDTO):Login {
return $login;
}

public function logByPersonAndGroup(PbsUserDTO $userDTO, Group $group) {
public function logByPersonAndGroup(PbsUserDTO $userDTO, Group $group)
{
$login = new Login();
$person = $this->personRepository->find($userDTO->getId());
$role = $this->permissionRepository->findHighestById($group, $person->getId());
Expand Down
22 changes: 13 additions & 9 deletions src/Service/Gamification/PersonGamificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public function __construct(
PersonRepository $personRepository,
EntityManagerInterface $em,
LevelUpLogRepository $levelUpLogRepository
)
{
) {
$this->loginRepository = $loginRepository;
$this->levelRepository = $levelRepository;
$this->personRepository = $personRepository;
Expand All @@ -53,7 +52,8 @@ public function __construct(
$this->levelUpLogRepository = $levelUpLogRepository;
}

public function reset(PbsUserDTO $pbsUserDTO) {
public function reset(PbsUserDTO $pbsUserDTO)
{
$person = $this->personRepository->find($pbsUserDTO->getId());
$pgp = $this->getPersonGamification($person);
$this->personGoalRepository->remove($pgp);
Expand All @@ -62,7 +62,7 @@ public function reset(PbsUserDTO $pbsUserDTO) {
public function getPersonGamification(Person $person): GamificationPersonProfile
{
$gamificationProfile = $person->getGamification();
if(is_null($gamificationProfile)) {
if (is_null($gamificationProfile)) {
$gamificationProfile = new GamificationPersonProfile();
$gamificationProfile->setLevel($this->levelRepository->findOneBy(['key' => 0]));
$gamificationProfile->setPerson($person);
Expand All @@ -80,7 +80,8 @@ public function getPersonGamification(Person $person): GamificationPersonProfile
return $gamificationProfile;
}

public function genericGoalProgress(PbsUserDTO $pbsUserDTO, string $type) {
public function genericGoalProgress(PbsUserDTO $pbsUserDTO, string $type)
{
$person = $this->personRepository->find($pbsUserDTO->getId());
$pgp = $this->getPersonGamification($person);

Expand Down Expand Up @@ -127,7 +128,8 @@ public function genericGoalProgress(PbsUserDTO $pbsUserDTO, string $type) {
$this->em->flush();
}

public function checkLevelUp(GamificationPersonProfile $person) {
public function checkLevelUp(GamificationPersonProfile $person)
{
$currentLevel = $person->getLevel();
$nextLevel = $this->levelRepository->findNextLevel($currentLevel);

Expand Down Expand Up @@ -178,18 +180,20 @@ public function checkLevelUp(GamificationPersonProfile $person) {
return $person;
}

private function resetLevelUp(Person $person) {
private function resetLevelUp(Person $person)
{
$levelUps = $this->levelUpLogRepository->findBy(['person' => $person->getId()]);
foreach ($levelUps as $levelUp) {
$this->levelUpLogRepository->remove($levelUp);
}
}

public function checkLoginGoal(GamificationPersonProfile $profile): bool {
public function checkLoginGoal(GamificationPersonProfile $profile): bool
{
return count($profile->getPerson()->getLogins()) >= 4;
}

public function getPersonGamificationDTO(PbsUserDTO $pbsUserDTO, String $locale): PersonGamificationDTO
public function getPersonGamificationDTO(PbsUserDTO $pbsUserDTO, string $locale): PersonGamificationDTO
{
$levels = $this->levelRepository->findBy(['type' => Level::USER]);
/** @var Person $person */
Expand Down
6 changes: 3 additions & 3 deletions src/Service/Gamification/QuapGamificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class QuapGamificationService
public function __construct(
PersonGamificationService $personGamificationService,
AggregatedQuapRepository $aggregatedQuapRepository
)
{
) {
$this->personGamificationService = $personGamificationService;
$this->aggregatedQuapRepository = $aggregatedQuapRepository;
}
Expand Down Expand Up @@ -62,7 +61,8 @@ public function processQuapEvent(array $newAnswers, Group $group, PbsUserDTO $pb
}
}

private function isQuestionnaireFullyAnswered($questionnaire) {
private function isQuestionnaireFullyAnswered($questionnaire)
{
foreach ($questionnaire as $answer) {
if ($answer === 0) {
return false;
Expand Down

0 comments on commit dcd889d

Please sign in to comment.