<commit_before><?php

namespace App\Containers\Authorization\UI\CLI\Commands;

use Apiato\Core\Foundation\Facades\Apiato;
use App\Containers\Authorization\Exceptions\RoleNotFoundException;
use App\Ship\Parents\Commands\ConsoleCommand;

class GiveAllPermissionsToRole extends ConsoleCommand
{

    protected $signature = 'apiato:permissions:toRole {role}';

    protected $description = 'Give all system Permissions to a specific Role.';

    public function handle()
    {
        $roleName = $this->argument('role');

        $allPermissionsNames = Apiato::call('Authorization@GetAllPermissionsTask', [true]);

        $role = Apiato::call('Authorization@FindRoleTask', [$roleName]);

        if(!$role){
            throw new RoleNotFoundException("Role $roleName is not found!");
        }

        $role->syncPermissions($allPermissionsNames = $allPermissionsNames->pluck('name')->toArray());

        $this->info('Gave the Role (' . $roleName . ') the following Permissions: ' . implode(' - ',
                $allPermissionsNames) . '.');
    }
}<commit_msg>refactor the GiveAllPermissionsToRole command class<commit_after><?php

namespace App\Containers\Authorization\UI\CLI\Commands;

use Apiato\Core\Foundation\Facades\Apiato;
use App\Containers\Authorization\Exceptions\RoleNotFoundException;
use App\Ship\Parents\Commands\ConsoleCommand;

/**
 * Class GiveAllPermissionsToRole
 *
 * @author  <NAME>  <<EMAIL>>
 */
class GiveAllPermissionsToRole extends ConsoleCommand
{

    protected $signature = 'apiato:permissions:toRole {role}';

    protected $description = 'Give all system Permissions to a specific Role.';

    /**
     * @void
     */
    public function handle()
    {
        $roleName = $this->argument('role');

        $allPermissions = Apiato::call('Authorization@GetAllPermissionsTask', [true]);

        $role = Apiato::call('Authorization@FindRoleTask', [$roleName]);

        if (!$role) {
            throw new RoleNotFoundException("Role $roleName is not found!");
        }

        $role->syncPermissions($allPermissionsNames = $allPermissions->pluck('name')->toArray());

        $this->info('Gave the Role (' . $roleName . ') the following Permissions: ' . implode(' - ',
                $allPermissionsNames) . '.');
    }
}
{'fraction_non_alphanumeric': 0.13704686118479223, 'fraction_numerical': 0.0, 'mean_word_length': 3.646817248459959, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6274074', 'n_tokens_mistral': 632, 'n_tokens_neox': 649, 'n_words': 125}