Passed
Push — master ( 44d4b0...6f1a5c )
by masoud
11:19
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/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/Abstracts/InitClass.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 {
12 12
     public Client $HttpClient;
13 13
     public ?VmSource $vmSource;
14
-    public function __construct(Client $HttpClient,?VmSource $vmSource=null)
14
+    public function __construct(Client $HttpClient, ?VmSource $vmSource=null)
15 15
     {
16 16
         $this->HttpClient=$HttpClient;
17 17
         $this->vmSource=$vmSource;
Please login to merge, or discard this patch.
src/Api/VM/Hardware/Hardware.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@
 block discarded – undo
11 11
 
12 12
 class Hardware extends InitClass
13 13
 {
14
-    public function cdrom(){
15
-        return new CDROM\CDROM($this->HttpClient,$this->vmSource);
14
+    public function cdrom() {
15
+        return new CDROM\CDROM($this->HttpClient, $this->vmSource);
16 16
     }
17
-    public function boot(){
18
-        return new Boot($this->HttpClient,$this->vmSource);
17
+    public function boot() {
18
+        return new Boot($this->HttpClient, $this->vmSource);
19 19
     }
20 20
 
21 21
 }
22 22
\ No newline at end of file
Please login to merge, or discard this patch.
src/Api/VM/Resources/Resources.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@
 block discarded – undo
9 9
 
10 10
 class Resources extends InitClass
11 11
 {
12
-    public function hardware(){
13
-        return new Hardware($this->HttpClient,$this->vmSource);
12
+    public function hardware() {
13
+        return new Hardware($this->HttpClient, $this->vmSource);
14 14
     }
15 15
 
16 16
 }
17 17
\ No newline at end of file
Please login to merge, or discard this patch.
src/Api/VM/Power/Power.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,31 +16,31 @@
 block discarded – undo
16 16
     /**
17 17
      * Returns the power state information of a virtual machine
18 18
      */
19
-    public function power($moid=null){
19
+    public function power($moid=null) {
20 20
         return ApiResponse::BodyResponse($this->HttpClient->get("vcenter/vm/{$this->getMoid($moid)}/power"));
21 21
     }
22 22
     /**
23 23
      * Returns the power state information of a virtual machine
24 24
      */
25
-    public function powerOff($moid=null){
25
+    public function powerOff($moid=null) {
26 26
         return !ApiResponse::HasError($this->HttpClient->post("vcenter/vm/{$this->getMoid($moid)}/power/stop"));
27 27
     }
28 28
     /**
29 29
      * Powers on a powered-off or suspended virtual machine
30 30
      */
31
-    public function powerOn($moid=null){
31
+    public function powerOn($moid=null) {
32 32
         return !ApiResponse::HasError($this->HttpClient->post("vcenter/vm/{$this->getMoid($moid)}/power/start"));
33 33
     }
34 34
     /**
35 35
      * Resets a powered-on virtual machine
36 36
      */
37
-    public function reset($moid=null){
37
+    public function reset($moid=null) {
38 38
         return !ApiResponse::HasError($this->HttpClient->post("vcenter/vm/{$this->getMoid($moid)}/power/reset"));
39 39
     }
40 40
     /**
41 41
      * Returns the power state information of a virtual machine
42 42
      */
43
-    public function suspend($moid=null){
43
+    public function suspend($moid=null) {
44 44
         return !ApiResponse::HasError($this->HttpClient->post("vcenter/vm/{$this->getMoid($moid)}/power/suspend"));
45 45
     }
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.