apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -39,6 +39,6 @@ class ActivityValidity extends Constraint
public function makeIsRequiredMessage(string $property)
{
return self::ROOT_MESSAGE . $property . self::IS_REQUIRED_MESSAGE;
return self::ROOT_MESSAGE.$property.self::IS_REQUIRED_MESSAGE;
}
}

View File

@@ -18,9 +18,6 @@ use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use function array_merge;
use function count;
class ActivityValidityValidator extends ConstraintValidator
{
public function validate($activity, Constraint $constraint)
@@ -33,106 +30,106 @@ class ActivityValidityValidator extends ConstraintValidator
throw new UnexpectedValueException($activity, Activity::class);
}
if ($activity->getActivityType()->getPersonsVisible() === 2 && count($activity->getPersons()) === 0) {
if (2 === $activity->getActivityType()->getPersonsVisible() && 0 === \count($activity->getPersons())) {
$this->context
->buildViolation($constraint->noPersonsMessage)
->addViolation();
}
if ($activity->getActivityType()->getUsersVisible() === 2 && count($activity->getUsers()) === 0) {
if (2 === $activity->getActivityType()->getUsersVisible() && 0 === \count($activity->getUsers())) {
$this->context
->buildViolation($constraint->noUsersMessage)
->addViolation();
}
if ($activity->getActivityType()->getThirdPartiesVisible() === 2 && count($activity->getThirdParties()) === 0) {
if (2 === $activity->getActivityType()->getThirdPartiesVisible() && 0 === \count($activity->getThirdParties())) {
$this->context
->buildViolation($constraint->noThirdPartiesMessage)
->addViolation();
}
if ($activity->getActivityType()->getUserVisible() === 2 && null === $activity->getUser()) {
if (2 === $activity->getActivityType()->getUserVisible() && null === $activity->getUser()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('user'))
->addViolation();
}
if ($activity->getActivityType()->getDateVisible() === 2 && null === $activity->getDate()) {
if (2 === $activity->getActivityType()->getDateVisible() && null === $activity->getDate()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('date'))
->addViolation();
}
if ($activity->getActivityType()->getLocationVisible() === 2 && null === $activity->getLocation()) {
if (2 === $activity->getActivityType()->getLocationVisible() && null === $activity->getLocation()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('location'))
->addViolation();
}
if ($activity->getActivityType()->getDurationTimeVisible() === 2 && null === $activity->getDurationTime()) {
if (2 === $activity->getActivityType()->getDurationTimeVisible() && null === $activity->getDurationTime()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('duration time'))
->addViolation();
}
if ($activity->getActivityType()->getTravelTimeVisible() === 2 && null === $activity->getTravelTime()) {
if (2 === $activity->getActivityType()->getTravelTimeVisible() && null === $activity->getTravelTime()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('travel time'))
->addViolation();
}
if ($activity->getActivityType()->getAttendeeVisible() === 2 && null === $activity->getAttendee()) {
if (2 === $activity->getActivityType()->getAttendeeVisible() && null === $activity->getAttendee()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('attendee'))
->addViolation();
}
if ($activity->getActivityType()->getReasonsVisible() === 2 && null === $activity->getReasons()) {
if (2 === $activity->getActivityType()->getReasonsVisible() && null === $activity->getReasons()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('reasons'))
->addViolation();
}
if ($activity->getActivityType()->getCommentVisible() === 2 && null === $activity->getComment()) {
if (2 === $activity->getActivityType()->getCommentVisible() && null === $activity->getComment()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('comment'))
->addViolation();
}
if ($activity->getActivityType()->getSentReceivedVisible() === 2 && null === $activity->getSentReceived()) {
if (2 === $activity->getActivityType()->getSentReceivedVisible() && null === $activity->getSentReceived()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('sent/received'))
->addViolation();
}
if ($activity->getActivityType()->getDocumentsVisible() === 2 && null === $activity->getDocuments()) {
if (2 === $activity->getActivityType()->getDocumentsVisible() && null === $activity->getDocuments()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('document'))
->addViolation();
}
if ($activity->getActivityType()->getEmergencyVisible() === 2 && null === $activity->getEmergency()) {
if (2 === $activity->getActivityType()->getEmergencyVisible() && null === $activity->getEmergency()) {
$this->context
->buildViolation($constraint->makeIsRequiredMessage('emergency'))
->addViolation();
}
if ($activity->getActivityType()->getSocialIssuesVisible() === 2 && $activity->getSocialIssues()->count() === 0) {
if (2 === $activity->getActivityType()->getSocialIssuesVisible() && 0 === $activity->getSocialIssues()->count()) {
$this->context
->buildViolation($constraint->socialIssuesMessage)
->addViolation();
}
if ($activity->getActivityType()->getSocialActionsVisible() === 2 && $activity->getSocialActions()->count() === 0) {
if (2 === $activity->getActivityType()->getSocialActionsVisible() && 0 === $activity->getSocialActions()->count()) {
// check if a social action may be added
$actions = [];
foreach ($activity->getSocialIssues() as $socialIssue) {
/** @var SocialIssue $socialIssue */
$actions = array_merge($actions, $socialIssue->getRecursiveSocialActions()->toArray());
$actions = \array_merge($actions, $socialIssue->getRecursiveSocialActions()->toArray());
}
if (0 < count($actions)) {
if (0 < \count($actions)) {
$this->context
->buildViolation($constraint->socialActionsMessage)
->addViolation();