Issues (13)

src/VmwareApiClient.php (1 issue)

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
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')
50
        {
51
            return parse_url($url, PHP_URL_SCHEME) === null ?
52
                $scheme."://" . $url : $url;
53
        }
54
    }
55
56