Test Failed
Push — master ( 8a0d16...cb6ca3 )
by masoud
11:09
created
src/Client/GuzzleClient.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@
 block discarded – undo
9 9
 
10 10
 class GuzzleClient extends Client
11 11
 {
12
-    public function __construct(VmwareApiClient $client,array $config = [])
12
+    public function __construct(VmwareApiClient $client, array $config=[])
13 13
     {
14
-        $guzzleConfig = array_merge([
14
+        $guzzleConfig=array_merge([
15 15
             'base_uri' => $client->getBaseUrl(),
16 16
             "verify"=>$client->ssl,
17 17
             'headers' => [
Please login to merge, or discard this patch.
src/ApiResponse.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@
 block discarded – undo
10 10
 class ApiResponse
11 11
 {
12 12
     const OK=200;
13
-    public static function BodyResponse(ResponseInterface $response){
13
+    public static function BodyResponse(ResponseInterface $response) {
14 14
         return json_decode($response->getBody());
15 15
     }
16
-    public static function HasError(ResponseInterface $response){
17
-        return !($response->getStatusCode()>=200 and $response->getStatusCode() <300);
16
+    public static function HasError(ResponseInterface $response) {
17
+        return !($response->getStatusCode()>=200 and $response->getStatusCode()<300);
18 18
     }
19 19
 }
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
src/Auth/SessionHandler.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,8 +36,9 @@
 block discarded – undo
36 36
     }
37 37
     public static function validateCredentials(VmwareApiClient $client)
38 38
     {
39
-        if((array_key_exists("username",$client->credential) && array_key_exists("password",$client->credential)) or array_key_exists("Vmware-Api-Session-Id",$client->credential))
40
-            return true;
39
+        if((array_key_exists("username",$client->credential) && array_key_exists("password",$client->credential)) or array_key_exists("Vmware-Api-Session-Id",$client->credential)) {
40
+                    return true;
41
+        }
41 42
         throw new CredentialException("required parameter you should send session-id or username-password for auth api ");
42 43
     }
43 44
     public static function convertCredentials($credentials){
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
 class SessionHandler
11 11
 {
12 12
     public static ?Client $client=null;
13
-    public static function getSession(VmwareApiClient $client){
13
+    public static function getSession(VmwareApiClient $client) {
14 14
         self::validateCredentials($client);
15 15
         return self::isSessionExist($client->credential) ? $client->credential['Vmware-Api-Session-Id'] : self::authRequest($client);
16 16
     }
17
-    public static function authRequest(VmwareApiClient $client){
17
+    public static function authRequest(VmwareApiClient $client) {
18 18
         $HttpClient=isset(static::$client) ? self::$client : new Client(
19 19
             [
20 20
                 "verify"=>$client->ssl,
@@ -25,23 +25,23 @@  discard block
 block discarded – undo
25 25
                 ]
26 26
             ]
27 27
         );
28
-        $response=$HttpClient->request('GET',$client->getAuthUrl(),[
28
+        $response=$HttpClient->request('GET', $client->getAuthUrl(), [
29 29
             "query"=>[
30 30
                 "~method"=>"post"
31 31
             ]
32 32
         ]);
33 33
         return json_decode($response->getBody())->value;
34 34
     }
35
-    public static function isSessionExist($credential){
36
-        return array_key_exists("Vmware-Api-Session-Id",$credential);
35
+    public static function isSessionExist($credential) {
36
+        return array_key_exists("Vmware-Api-Session-Id", $credential);
37 37
     }
38 38
     public static function validateCredentials(VmwareApiClient $client)
39 39
     {
40
-        if((array_key_exists("username",$client->credential) && array_key_exists("password",$client->credential)) or array_key_exists("Vmware-Api-Session-Id",$client->credential))
40
+        if ((array_key_exists("username", $client->credential) && array_key_exists("password", $client->credential)) or array_key_exists("Vmware-Api-Session-Id", $client->credential))
41 41
             return true;
42 42
         throw new CredentialException("required parameter you should send session-id or username-password for auth api ");
43 43
     }
44
-    public static function convertCredentials($credentials){
44
+    public static function convertCredentials($credentials) {
45 45
         return base64_encode($credentials['username'].":".$credentials['password']);
46 46
     }
47 47
 
Please login to merge, or discard this patch.
src/Api/VM/ConsoleTickets/ConsoleTickets.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
 class ConsoleTickets extends InitClass
13 13
 {
14 14
     use MOID;
15
-    public function createConsoleTickets(array $body,$moid=null){
16
-        return ApiResponse::BodyResponse($this->HttpClient->post("vm/{$this->getMoid($moid)}/console/tickets",[
15
+    public function createConsoleTickets(array $body, $moid=null) {
16
+        return ApiResponse::BodyResponse($this->HttpClient->post("vm/{$this->getMoid($moid)}/console/tickets", [
17 17
             RequestOptions::JSON=>$body
18 18
         ]));
19 19
     }
Please login to merge, or discard this patch.
src/Api/VM/Tools/Tools.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
     public function upgradeTools($body, $moid=null){
38 38
         return !ApiResponse::BodyResponse($this->HttpClient->post("vm/{$this->getMoid($moid)}/tools",[
39 39
             "query"=>[
40
-              "action"=>"upgrade"
40
+                "action"=>"upgrade"
41 41
             ],
42 42
             RequestOptions::JSON=>$body
43 43
         ]));
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
     /**
19 19
      * Get the properties of VMware Tools.
20 20
      */
21
-    public function tools($moid=null){
21
+    public function tools($moid=null) {
22 22
         return ApiResponse::BodyResponse($this->HttpClient->get("vm/{$this->getMoid($moid)}/tools"));
23 23
     }
24 24
 
25 25
     /**
26 26
      * Update the properties of VMware Tools.
27 27
      */
28
-    public function updateTools(array $body,$moid=null){
29
-        return !ApiResponse::HasError($this->HttpClient->patch("vm/{$this->getMoid($moid)}/tools",[
28
+    public function updateTools(array $body, $moid=null) {
29
+        return !ApiResponse::HasError($this->HttpClient->patch("vm/{$this->getMoid($moid)}/tools", [
30 30
             RequestOptions::JSON=>$body
31 31
         ]));
32 32
     }
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
     /**
35 35
      * Begins the Tools upgrade process. To monitor the status of the Tools upgrade, clients should check the Tools status by calling Tools.get and examining Tools.Info.version-status and Tools.Info.run-state.
36 36
      */
37
-    public function upgradeTools($body, $moid=null){
38
-        return !ApiResponse::BodyResponse($this->HttpClient->post("vm/{$this->getMoid($moid)}/tools",[
37
+    public function upgradeTools($body, $moid=null) {
38
+        return !ApiResponse::BodyResponse($this->HttpClient->post("vm/{$this->getMoid($moid)}/tools", [
39 39
             "query"=>[
40 40
               "action"=>"upgrade"
41 41
             ],
Please login to merge, or discard this patch.
src/Api/VM/ManageVms.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -5,22 +5,22 @@
 block discarded – undo
5 5
     use FNDEV\vShpare\Api\VM\Traits\IterableObject;
6 6
     use GuzzleHttp\Psr7\Response;
7 7
 
8
-    class ManageVms implements \Iterator,\Countable {
9
-        use IterableObject,CountAbleObject;
8
+    class ManageVms implements \Iterator, \Countable {
9
+        use IterableObject, CountAbleObject;
10 10
 
11
-        private array $items = [];
12
-        private int $position = 0;
13
-        public function __construct($vms,$HttpClient)
11
+        private array $items=[];
12
+        private int $position=0;
13
+        public function __construct($vms, $HttpClient)
14 14
         {
15
-            $this->parseObjects($vms,$HttpClient);
15
+            $this->parseObjects($vms, $HttpClient);
16 16
         }
17
-        public function parseObjects($vms,$HttpClient){
18
-            foreach ($vms->value as $VmProperties){
19
-                array_push($this->items,new VmSource($HttpClient,$VmProperties,$VmProperties->vm));
17
+        public function parseObjects($vms, $HttpClient) {
18
+            foreach ($vms->value as $VmProperties) {
19
+                array_push($this->items, new VmSource($HttpClient, $VmProperties, $VmProperties->vm));
20 20
             }
21 21
         }
22
-        public function first(){
23
-            return (count($this->items) >= 1) ? $this->items[0] : null ;
22
+        public function first() {
23
+            return (count($this->items)>=1) ? $this->items[0] : null;
24 24
         }
25 25
 
26 26
 
Please login to merge, or discard this patch.
src/Api/VM/Traits/IterableObject.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@
 block discarded – undo
20 20
     }
21 21
     public function valid()
22 22
     {
23
-        return array_key_exists($this->position,$this->items);
23
+        return array_key_exists($this->position, $this->items);
24 24
     }
25 25
     public function rewind()
26 26
     {
27
-        $this->position = 0;
27
+        $this->position=0;
28 28
     }
29 29
 
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
src/Api/VM/Traits/MOID.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@
 block discarded – undo
6 6
 
7 7
 trait MOID
8 8
 {
9
-    public function getMoid($moid=null){
10
-        if($moid)
9
+    public function getMoid($moid=null) {
10
+        if ($moid)
11 11
             return $moid;
12
-        if($this->vmSource && isset($this->vmSource->moid))
12
+        if ($this->vmSource && isset($this->vmSource->moid))
13 13
             return $this->vmSource->moid;
14 14
         throw new \InvalidArgumentException("provide moid or pass vmSource object");
15 15
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,10 +7,12 @@
 block discarded – undo
7 7
 trait MOID
8 8
 {
9 9
     public function getMoid($moid=null){
10
-        if($moid)
11
-            return $moid;
12
-        if($this->vmSource && isset($this->vmSource->moid))
13
-            return $this->vmSource->moid;
10
+        if($moid) {
11
+                    return $moid;
12
+        }
13
+        if($this->vmSource && isset($this->vmSource->moid)) {
14
+                    return $this->vmSource->moid;
15
+        }
14 16
         throw new \InvalidArgumentException("provide moid or pass vmSource object");
15 17
     }
16 18
 }
17 19
\ No newline at end of file
Please login to merge, or discard this patch.
src/Api/VM/GuestPower/GuestPower.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
     /**
17 17
      * Returns information about the guest operating system power state.
18 18
      */
19
-    public function power($moid=null){
19
+    public function power($moid=null) {
20 20
         return ApiResponse::BodyResponse($this->HttpClient->get("vm/{$this->getMoid($moid)}/guest/power"));
21 21
     }
22 22
     /**
23 23
      * Issues a request to the guest operating system asking it to perform a clean shutdown of all services. This request returns immediately and does not wait for the guest operating system to complete the operation.
24 24
      */
25
-    public function shutdown($moid=null){
26
-        return !ApiResponse::HasError($this->HttpClient->post("vm/{$this->getMoid($moid)}/guest/power",[
25
+    public function shutdown($moid=null) {
26
+        return !ApiResponse::HasError($this->HttpClient->post("vm/{$this->getMoid($moid)}/guest/power", [
27 27
             "query"=>[
28 28
                 "action"=>"shutdown"
29 29
             ]
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
     /**
33 33
      * Issues a request to the guest operating system asking it to perform a reboot. This request returns immediately and does not wait for the guest operating system to complete the operation
34 34
      */
35
-    public function reboot($moid=null){
36
-        return !ApiResponse::HasError($this->HttpClient->post("vm/{$this->getMoid($moid)}/guest/power",[
35
+    public function reboot($moid=null) {
36
+        return !ApiResponse::HasError($this->HttpClient->post("vm/{$this->getMoid($moid)}/guest/power", [
37 37
             "query"=>[
38 38
                 "action"=>"reboot"
39 39
             ]
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
     /**
43 43
      * Issues a request to the guest operating system asking it to perform a suspend operation.
44 44
      */
45
-    public function standby($moid=null){
46
-        return !ApiResponse::HasError($this->HttpClient->post("vm/{$this->getMoid($moid)}/guest/power",[
45
+    public function standby($moid=null) {
46
+        return !ApiResponse::HasError($this->HttpClient->post("vm/{$this->getMoid($moid)}/guest/power", [
47 47
             "query"=>[
48 48
                 "action"=>"standby"
49 49
             ]
Please login to merge, or discard this patch.