VmwareApiClient   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 4
Bugs 2 Features 0
Metric Value
eloc 26
c 4
b 2
f 0
dl 0
loc 45
rs 10
wmc 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getBaseUrl() 0 2 1
A setHttpClient() 0 2 1
A getAuthUrl() 0 2 1
A getSessionId() 0 2 1
A getHttpClient() 0 2 1
A __construct() 0 10 1
A addScheme() 0 4 2
A vm() 0 2 1
A tagging() 0 2 1
1
<?php
2
    namespace FNDEV\vShpare;
3
    use FNDEV\vShpare\Api\Tagging\Tagging;
4
    use FNDEV\vShpare\Api\VM\VM;
5
    use FNDEV\vShpare\Auth\SessionHandler;
6
    use FNDEV\vShpare\Client\GuzzleClient;
7
    use \GuzzleHttp\Client;
0 ignored issues
show
Bug introduced by
The type \GuzzleHttp\Client was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
    class VmwareApiClient{
9
        public $host;
10
        public $credential;
11
        public $HttpClient;
12
        public $ssl;
13
        public $baseUrl;
14
        public $authUrl;
15
        public $protocol;
16
        public $port;
17
        public function __construct($host,array $credential,$port=443,$ssl=false,$protocol="https",$baseurl="/rest/",$authurl="/rest/com/vmware/cis/session",?Client $client=null)
18
        {
19
            $this->host=$host;
20
            $this->port=$port;
21
            $this->credential=$credential;
22
            $this->ssl=$ssl;
23
            $this->baseUrl=$baseurl;
24
            $this->authUrl=$authurl;
25
            $this->protocol=$protocol;
26
            $this->HttpClient=$client??new GuzzleClient($this);
27
        }
28
        public function vm():VM{
29
            return new Api\VM\VM($this->HttpClient);
30
        }
31
        public function tagging():Tagging{
32
            return new Tagging($this->HttpClient);
33
        }
34
        public function getHttpClient(){
35
            return $this->HttpClient;
36
        }
37
        public function setHttpClient(Client $client){
38
            $this->HttpClient=$client;
39
        }
40
        public function getSessionId(){
41
            return SessionHandler::getSession($this);
42
        }
43
        public function getBaseUrl(){
44
            return $this->addScheme($this->host.":".$this->port."/".trim($this->baseUrl,"/")."/",$this->protocol);
45
        }
46
        public function getAuthUrl(){
47
            return  $this->addScheme($this->host.":".$this->port."/".trim($this->authUrl,"/"),$this->protocol);
48
        }
49
        function addScheme($url, $scheme = 'http')
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
50
        {
51
            return parse_url($url, PHP_URL_SCHEME) === null ?
52
                $scheme."://" . $url : $url;
53
        }
54
    }
55
56