TenantCredentials   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 51
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 11 2
1
<?php
2
3
namespace Slides\Saml2\Commands;
4
5
use Slides\Saml2\Helpers\ConsoleHelper;
6
use Slides\Saml2\Repositories\TenantRepository;
7
8
/**
9
 * Class TenantCredentials
10
 *
11
 * @package Slides\Saml2\Commands
12
 */
13
class TenantCredentials extends \Illuminate\Console\Command
14
{
15
    use RendersTenants;
0 ignored issues
show
introduced by
The trait Slides\Saml2\Commands\RendersTenants requires some properties which are not provided by Slides\Saml2\Commands\TenantCredentials: $uuid, $relay_state_url, $idp_x509_cert, $key, $idp_entity_id, $id, $name_id_format, $metadata, $created_at, $idp_logout_url, $idp_login_url, $updated_at, $deleted_at
Loading history...
16
17
    /**
18
     * The name and signature of the console command.
19
     *
20
     * @var string
21
     */
22
    protected $signature = 'saml2:tenant-credentials {id}';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = 'List tenant credentials for IdP';
30
31
    /**
32
     * @var TenantRepository
33
     */
34
    protected $tenants;
35
36
    /**
37
     * DeleteTenant constructor.
38
     *
39
     * @param TenantRepository $tenants
40
     */
41
    public function __construct(TenantRepository $tenants)
42
    {
43
        $this->tenants = $tenants;
44
45
        parent::__construct();
46
    }
47
48
    /**
49
     * Execute the console command.
50
     *
51
     * @return void
52
     */
53
    public function handle()
54
    {
55
        if(!$tenant = $this->tenants->findById($this->argument('id'))) {
0 ignored issues
show
Bug introduced by
$this->argument('id') of type array|null|string is incompatible with the type integer expected by parameter $id of Slides\Saml2\Repositorie...tRepository::findById(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

55
        if(!$tenant = $this->tenants->findById(/** @scrutinizer ignore-type */ $this->argument('id'))) {
Loading history...
56
            $this->error('Cannot find a tenant #' . $this->argument('id'));
0 ignored issues
show
Bug introduced by
Are you sure $this->argument('id') of type array|null|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

56
            $this->error('Cannot find a tenant #' . /** @scrutinizer ignore-type */ $this->argument('id'));
Loading history...
57
            return;
58
        }
59
60
        $this->renderTenants($tenant, 'The tenant model');
61
        $this->renderTenantCredentials($tenant);
62
63
        $this->output->newLine();
64
    }
65
}