Skip to content

Commit

Permalink
fix phpstan test
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Oct 20, 2023
1 parent 9818e65 commit e826bcf
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Util/User/UserUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@ public function __construct(

public function findActiveUsersByGroup(array $groups, string $type = self::TYPE_USER, array $options = []): ?Collection
{
match ($type) {
self::TYPE_USER => $table = UserModel::getTable(),
self::TYPE_MEMBER => $table = MemberModel::getTable(),
$table = match ($type) {
self::TYPE_USER => UserModel::getTable(),
self::TYPE_MEMBER => MemberModel::getTable(),
default => throw new \InvalidArgumentException(sprintf('Invalid type "%s" given.', $type)),
};

/** @var class-string<Model> $modelClass */
$modelClass = $this->contaoFramework->getAdapter(Model::class)->getClassFromTable($table);

if (!$modelClass) {
return null;
}

if (!\is_array($groups) || empty($groups = array_filter($groups, function ($k) {
return !empty($k) && is_numeric($k);
}))) {
Expand Down Expand Up @@ -82,8 +86,6 @@ public function getActiveGroups(UserModel|MemberModel $user): ?Collection
$groupTable = 'tl_user_group';
}

// $groupTable = $user::getTable() .'_group';

$columns = [$groupTable.'.id IN('.implode(',', array_map('\intval', $groups)).')'];

$this->modelUtil->addPublishedCheckToModelArrays($groupTable, $columns, [
Expand Down

0 comments on commit e826bcf

Please sign in to comment.