herpaderpaldent/seat-groups

View on GitHub
src/Actions/Sync/CatchSuperuserAction.php

Summary

Maintainability
A
25 mins
Test Coverage
<?php
 
namespace Herpaderpaldent\Seat\SeatGroups\Actions\Sync;
 
use Seat\Web\Models\Group;
 
class CatchSuperuserAction
{
protected $group;
 
protected $roles;
 
public function __construct()
{
$this->roles = collect();
}
 
Function `execute` has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
public function execute(Group $group)
{
$this->group = $group;
 
//Catch superuser permissions
foreach ($this->group->roles as $role) {
foreach ($role->permissions as $permission) {
if ($permission->title === 'superuser') {
$this->roles->push($role->id);
}
}
}
 
return $this->roles;
}
}