Test Setup Failed
Push — 0.1-dev ( 3ceb1a...383a4b )
by Petr
02:14
created
src/Core/Request.php 3 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -147,7 +147,8 @@
 block discarded – undo
147 147
      * @param  \SimpleXMLElement $from
148 148
      * @return void
149 149
      */
150
-    private function sxmlAppend(\SimpleXMLElement $to, \SimpleXMLElement $from) {
150
+    private function sxmlAppend(\SimpleXMLElement $to, \SimpleXMLElement $from)
151
+    {
151 152
         $toDom = dom_import_simplexml($to);
152 153
         $fromDom = dom_import_simplexml($from);
153 154
         $toDom->appendChild($toDom->ownerDocument->importNode($fromDom, true));
Please login to merge, or discard this patch.
Indentation   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -8,51 +8,51 @@  discard block
 block discarded – undo
8 8
 class Request
9 9
 {
10 10
 
11
-    /**
12
-     * Base URL
13
-     * @var string
14
-     */
15
-    const BASE_URL = 'https://api.yourmembership.com';
16
-    const API_VERSION = '2.25';
17
-
18
-    /**
19
-     * Session ID use for YourMembership API
20
-     * @var string
21
-     */
22
-    private static $sessionId = null;
23
-    /**
24
-     * Call Counter for Your Membership for a given session
25
-     * @var integer
26
-     */
27
-    public static $callId = 0;
28
-    /**
29
-     * API Key Used for YourMembership API
30
-     * @var string
31
-     */
32
-    private $apiKey;
33
-    /**
34
-     * Sa Passcode is a supplementary API key used for YourMembership API
35
-     * @var string
36
-     */
37
-    private $saPasscode;
38
-
39
-
40
-    public function __construct(string $apiKey, string $saPasscode)
41
-    {
42
-        $this->apiKey = $apiKey;
43
-        $this->saPasscode = $saPasscode;
44
-    }
45
-
46
-    /**
47
-     * Create the Base Envelope for an API call to YourMembership
48
-     * @method buildBasePayload
49
-     * @author PA
50
-     * @date   2017-01-09
51
-     * @return \SimpleXMLElement  XML Envelope with necessary credential parameters
52
-     */
53
-    public function buildBasePayload() : \SimpleXMLElement
54
-    {
55
-        /*
11
+	/**
12
+	 * Base URL
13
+	 * @var string
14
+	 */
15
+	const BASE_URL = 'https://api.yourmembership.com';
16
+	const API_VERSION = '2.25';
17
+
18
+	/**
19
+	 * Session ID use for YourMembership API
20
+	 * @var string
21
+	 */
22
+	private static $sessionId = null;
23
+	/**
24
+	 * Call Counter for Your Membership for a given session
25
+	 * @var integer
26
+	 */
27
+	public static $callId = 0;
28
+	/**
29
+	 * API Key Used for YourMembership API
30
+	 * @var string
31
+	 */
32
+	private $apiKey;
33
+	/**
34
+	 * Sa Passcode is a supplementary API key used for YourMembership API
35
+	 * @var string
36
+	 */
37
+	private $saPasscode;
38
+
39
+
40
+	public function __construct(string $apiKey, string $saPasscode)
41
+	{
42
+		$this->apiKey = $apiKey;
43
+		$this->saPasscode = $saPasscode;
44
+	}
45
+
46
+	/**
47
+	 * Create the Base Envelope for an API call to YourMembership
48
+	 * @method buildBasePayload
49
+	 * @author PA
50
+	 * @date   2017-01-09
51
+	 * @return \SimpleXMLElement  XML Envelope with necessary credential parameters
52
+	 */
53
+	public function buildBasePayload() : \SimpleXMLElement
54
+	{
55
+		/*
56 56
             <YourMembership>
57 57
             <Version>2.25</Version>
58 58
             <ApiKey>3D638C5F-CCE2-4638-A2C1-355FA7BBC917</ApiKey>
@@ -60,168 +60,168 @@  discard block
 block discarded – undo
60 60
             <SaPasscode>************</SaPasscode>
61 61
             </YourMembership>
62 62
         */
63
-        $xml = new \SimpleXMLElement('<YourMembership></YourMembership>');
64
-        $xml->addChild('Version', self::API_VERSION);
65
-        $xml->addChild('ApiKey', $this->apiKey);
66
-        $xml->addChild('CallID', self::$callId);
67
-        $xml->addChild('SaPasscode', $this->saPasscode);
68
-
69
-        return $xml;
70
-    }
71
-
72
-    /**
73
-     * Generates the XML for a API method call within
74
-     * @method createCallPayload
75
-     * @author PA
76
-     * @date   2017-01-09
77
-     * @param  string            $method    YourMembership API Function Name
78
-     * @param  array             $arguments Array of Arguments to be passed as part of the YourMembership "Call"
79
-     * @return \SimpleXMLElement
80
-     */
81
-    public function createCallPayload(string $method, array $arguments) : \SimpleXMLElement
82
-    {
83
-        //Create Call Node
84
-        $call = new \SimpleXMLElement('<Call> </Call>');
85
-        $call->addAttribute('Method', $method);
86
-
87
-        //Add Arguments to the Call Node
88
-
89
-        $call = $this->sxmlAddChildrenRecursive($call,$arguments);
90
-
91
-        return $call;
92
-    }
93
-    /**
94
-     * Recursively builds the array into a XML Tree
95
-     * //NOTE Child arrays must be associative
96
-     * @method sxmlAddChildrenRecursive
97
-     * @author PA
98
-     * @date   2017-01-12
99
-     * @param  SimpleXMLElement         $root      Root XML Node
100
-     * @param  array                    $arguments Array of Arguments to be added to XML Node
101
-     * @return SimpleXMLElement                    Resulting XML Tree
102
-     */
103
-    private function sxmlAddChildrenRecursive(\SimpleXMLElement $root, array $arguments) : \SimpleXMLElement
104
-    {
105
-        foreach ($arguments as $key => $value) {
106
-            if (is_array($value)) {
107
-                try {
108
-                    $child = new \SimpleXMLElement(sprintf('<%s></%s>',$key, $key));
109
-                    $this->sxmlAddChildrenRecursive($child, $value);
110
-                    $this->sxmlAppend($root,$child);
111
-                } catch(\Exception $e) {
112
-                    throw new YourMembershipException($e->getMessage(), $e->getCode(), $e);
113
-                }
114
-            } else {
115
-                $root->addChild($key, $value);
116
-            }
117
-
118
-        }
119
-        return $root;
120
-    }
121
-    /**
122
-     * Builds The XML Request Body for the Your Membership API Call
123
-     * @method buildXMLBody
124
-     * @author PA
125
-     * @date   2017-01-10
126
-     * @param  string            $method    Your Membership API Function Name
127
-     * @param  array             $arguments Your Membership Arguments
128
-     * @return \SimpleXMLElement
129
-     */
130
-    public function buildXMLBody(string $method, array $arguments) : \SimpleXMLElement
131
-    {
132
-        $xml = $this->buildBasePayload(); // Common Envelope
133
-
134
-        if ($this->isSessionRequiredForMethod($method)) {
135
-            $xml = $this->addSessionIdToRequest($xml);
136
-        }
137
-
138
-        $callPayload = $this->createCallPayload($method, $arguments); // Specific API Call Envelope
139
-
140
-        // Put Api call into common envelope
141
-        $this->sxmlAppend($xml, $callPayload);
142
-
143
-        return $xml;
144
-    }
145
-    /**
146
-     * Builds a Guzzle Request Object
147
-     * @method buildRequest
148
-     * @author PA
149
-     * @date   2017-01-11
150
-     * @param  string        $method    YourMembership API Method
151
-     * @param  array         $arguments YourMembership API Method Call Arguments
152
-     * @return \GuzzleHttp\Psr7\Request            Guzzle Request Object
153
-     */
154
-    public function buildRequest(string $method, array $arguments) : \GuzzleHttp\Psr7\Request
155
-    {
156
-        $requestBody = $this->buildXMLBody($method, $arguments)->asXML();
157
-        return new GuzzleRequest('POST', self::BASE_URL, ['Content-Type' => 'application/x-www-form-urlencoded; charset=UTF8'], $requestBody);
158
-    }
159
-
160
-    /**
161
-     * Checks if Request Requires Session ID
162
-     * @method isSessionRequiredForMethod
163
-     * @author PA
164
-     * @date   2017-01-10
165
-     * @param  string                     $method YourMembership API Method
166
-     * @return bool
167
-     */
168
-    public function isSessionRequiredForMethod(string $method) : bool
169
-    {
170
-        //TODO Add config Logic for what API Methods require Session ID
171
-        return ($method != 'Session.Create');
172
-    }
173
-
174
-    /**
175
-     * Helper for Deep Copy for of $from element into $to element for SimpleXML
176
-     * @method sxmlAppend
177
-     * @author PA
178
-     * @date   2017-01-09
179
-     * @param  \SimpleXMLElement $to
180
-     * @param  \SimpleXMLElement $from
181
-     * @return void
182
-     */
183
-    private function sxmlAppend(\SimpleXMLElement $to, \SimpleXMLElement $from) {
184
-        $toDom = dom_import_simplexml($to);
185
-        $fromDom = dom_import_simplexml($from);
186
-        $toDom->appendChild($toDom->ownerDocument->importNode($fromDom, true));
187
-    }
188
-
189
-    /**
190
-     * Adds the Session Variable to the given XML Request Payload
191
-     * @method addSessionIdToRequest
192
-     * @author PA
193
-     * @date   2017-01-10
194
-     * @param  \SimpleXMLElement                $requestXML Base Request XML Payload
195
-     */
196
-    private function addSessionIdToRequest(\SimpleXMLElement $requestXML) : \SimpleXMLElement
197
-    {
198
-        $requestXML->addChild('SessionID', self::$sessionId);
199
-        return $requestXML;
200
-    }
201
-
202
-
203
-    /**
204
-     * Setter Method for SessionID
205
-     * @method setSessionId
206
-     * @author PA
207
-     * @date   2017-01-10
208
-     * @param  string       $sessionId YourMembership Session ID
209
-     */
210
-    public static function setSessionId(string $sessionId)
211
-    {
212
-        self::$sessionId = $sessionId;
213
-    }
214
-
215
-    /**
216
-     * Checks if we have an active session available
217
-     * @method hasSession
218
-     * @author PA
219
-     * @date   2017-01-11
220
-     * @return boolean
221
-     */
222
-    public function hasSession()
223
-    {
224
-        return !is_null(self::$sessionId);
225
-    }
63
+		$xml = new \SimpleXMLElement('<YourMembership></YourMembership>');
64
+		$xml->addChild('Version', self::API_VERSION);
65
+		$xml->addChild('ApiKey', $this->apiKey);
66
+		$xml->addChild('CallID', self::$callId);
67
+		$xml->addChild('SaPasscode', $this->saPasscode);
68
+
69
+		return $xml;
70
+	}
71
+
72
+	/**
73
+	 * Generates the XML for a API method call within
74
+	 * @method createCallPayload
75
+	 * @author PA
76
+	 * @date   2017-01-09
77
+	 * @param  string            $method    YourMembership API Function Name
78
+	 * @param  array             $arguments Array of Arguments to be passed as part of the YourMembership "Call"
79
+	 * @return \SimpleXMLElement
80
+	 */
81
+	public function createCallPayload(string $method, array $arguments) : \SimpleXMLElement
82
+	{
83
+		//Create Call Node
84
+		$call = new \SimpleXMLElement('<Call> </Call>');
85
+		$call->addAttribute('Method', $method);
86
+
87
+		//Add Arguments to the Call Node
88
+
89
+		$call = $this->sxmlAddChildrenRecursive($call,$arguments);
90
+
91
+		return $call;
92
+	}
93
+	/**
94
+	 * Recursively builds the array into a XML Tree
95
+	 * //NOTE Child arrays must be associative
96
+	 * @method sxmlAddChildrenRecursive
97
+	 * @author PA
98
+	 * @date   2017-01-12
99
+	 * @param  SimpleXMLElement         $root      Root XML Node
100
+	 * @param  array                    $arguments Array of Arguments to be added to XML Node
101
+	 * @return SimpleXMLElement                    Resulting XML Tree
102
+	 */
103
+	private function sxmlAddChildrenRecursive(\SimpleXMLElement $root, array $arguments) : \SimpleXMLElement
104
+	{
105
+		foreach ($arguments as $key => $value) {
106
+			if (is_array($value)) {
107
+				try {
108
+					$child = new \SimpleXMLElement(sprintf('<%s></%s>',$key, $key));
109
+					$this->sxmlAddChildrenRecursive($child, $value);
110
+					$this->sxmlAppend($root,$child);
111
+				} catch(\Exception $e) {
112
+					throw new YourMembershipException($e->getMessage(), $e->getCode(), $e);
113
+				}
114
+			} else {
115
+				$root->addChild($key, $value);
116
+			}
117
+
118
+		}
119
+		return $root;
120
+	}
121
+	/**
122
+	 * Builds The XML Request Body for the Your Membership API Call
123
+	 * @method buildXMLBody
124
+	 * @author PA
125
+	 * @date   2017-01-10
126
+	 * @param  string            $method    Your Membership API Function Name
127
+	 * @param  array             $arguments Your Membership Arguments
128
+	 * @return \SimpleXMLElement
129
+	 */
130
+	public function buildXMLBody(string $method, array $arguments) : \SimpleXMLElement
131
+	{
132
+		$xml = $this->buildBasePayload(); // Common Envelope
133
+
134
+		if ($this->isSessionRequiredForMethod($method)) {
135
+			$xml = $this->addSessionIdToRequest($xml);
136
+		}
137
+
138
+		$callPayload = $this->createCallPayload($method, $arguments); // Specific API Call Envelope
139
+
140
+		// Put Api call into common envelope
141
+		$this->sxmlAppend($xml, $callPayload);
142
+
143
+		return $xml;
144
+	}
145
+	/**
146
+	 * Builds a Guzzle Request Object
147
+	 * @method buildRequest
148
+	 * @author PA
149
+	 * @date   2017-01-11
150
+	 * @param  string        $method    YourMembership API Method
151
+	 * @param  array         $arguments YourMembership API Method Call Arguments
152
+	 * @return \GuzzleHttp\Psr7\Request            Guzzle Request Object
153
+	 */
154
+	public function buildRequest(string $method, array $arguments) : \GuzzleHttp\Psr7\Request
155
+	{
156
+		$requestBody = $this->buildXMLBody($method, $arguments)->asXML();
157
+		return new GuzzleRequest('POST', self::BASE_URL, ['Content-Type' => 'application/x-www-form-urlencoded; charset=UTF8'], $requestBody);
158
+	}
159
+
160
+	/**
161
+	 * Checks if Request Requires Session ID
162
+	 * @method isSessionRequiredForMethod
163
+	 * @author PA
164
+	 * @date   2017-01-10
165
+	 * @param  string                     $method YourMembership API Method
166
+	 * @return bool
167
+	 */
168
+	public function isSessionRequiredForMethod(string $method) : bool
169
+	{
170
+		//TODO Add config Logic for what API Methods require Session ID
171
+		return ($method != 'Session.Create');
172
+	}
173
+
174
+	/**
175
+	 * Helper for Deep Copy for of $from element into $to element for SimpleXML
176
+	 * @method sxmlAppend
177
+	 * @author PA
178
+	 * @date   2017-01-09
179
+	 * @param  \SimpleXMLElement $to
180
+	 * @param  \SimpleXMLElement $from
181
+	 * @return void
182
+	 */
183
+	private function sxmlAppend(\SimpleXMLElement $to, \SimpleXMLElement $from) {
184
+		$toDom = dom_import_simplexml($to);
185
+		$fromDom = dom_import_simplexml($from);
186
+		$toDom->appendChild($toDom->ownerDocument->importNode($fromDom, true));
187
+	}
188
+
189
+	/**
190
+	 * Adds the Session Variable to the given XML Request Payload
191
+	 * @method addSessionIdToRequest
192
+	 * @author PA
193
+	 * @date   2017-01-10
194
+	 * @param  \SimpleXMLElement                $requestXML Base Request XML Payload
195
+	 */
196
+	private function addSessionIdToRequest(\SimpleXMLElement $requestXML) : \SimpleXMLElement
197
+	{
198
+		$requestXML->addChild('SessionID', self::$sessionId);
199
+		return $requestXML;
200
+	}
201
+
202
+
203
+	/**
204
+	 * Setter Method for SessionID
205
+	 * @method setSessionId
206
+	 * @author PA
207
+	 * @date   2017-01-10
208
+	 * @param  string       $sessionId YourMembership Session ID
209
+	 */
210
+	public static function setSessionId(string $sessionId)
211
+	{
212
+		self::$sessionId = $sessionId;
213
+	}
214
+
215
+	/**
216
+	 * Checks if we have an active session available
217
+	 * @method hasSession
218
+	 * @author PA
219
+	 * @date   2017-01-11
220
+	 * @return boolean
221
+	 */
222
+	public function hasSession()
223
+	{
224
+		return !is_null(self::$sessionId);
225
+	}
226 226
 
227 227
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
         //Add Arguments to the Call Node
88 88
 
89
-        $call = $this->sxmlAddChildrenRecursive($call,$arguments);
89
+        $call = $this->sxmlAddChildrenRecursive($call, $arguments);
90 90
 
91 91
         return $call;
92 92
     }
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
         foreach ($arguments as $key => $value) {
106 106
             if (is_array($value)) {
107 107
                 try {
108
-                    $child = new \SimpleXMLElement(sprintf('<%s></%s>',$key, $key));
108
+                    $child = new \SimpleXMLElement(sprintf('<%s></%s>', $key, $key));
109 109
                     $this->sxmlAddChildrenRecursive($child, $value);
110
-                    $this->sxmlAppend($root,$child);
111
-                } catch(\Exception $e) {
110
+                    $this->sxmlAppend($root, $child);
111
+                } catch (\Exception $e) {
112 112
                     throw new YourMembershipException($e->getMessage(), $e->getCode(), $e);
113 113
                 }
114 114
             } else {
Please login to merge, or discard this patch.
src/YourMembershipClient.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -9,57 +9,57 @@
 block discarded – undo
9 9
 class YourMembershipClient
10 10
 {
11 11
 
12
-    /**
13
-     * Guzzle Client
14
-     * @var \GuzzleHttp\Client
15
-     */
16
-    private $client;
17
-    /**
18
-     * YourMembership Request
19
-     * @var Request
20
-     */
21
-    private $request;
12
+	/**
13
+	 * Guzzle Client
14
+	 * @var \GuzzleHttp\Client
15
+	 */
16
+	private $client;
17
+	/**
18
+	 * YourMembership Request
19
+	 * @var Request
20
+	 */
21
+	private $request;
22 22
 
23
-    public function __construct(Client $client, string $apiKey, string $saPasscode)
24
-    {
25
-        $this->client = $client;
26
-        $this->request = new Request($apiKey, $saPasscode);
27
-        $sessionID = $this->createSession();
28
-        Request::setSessionID($sessionID);
23
+	public function __construct(Client $client, string $apiKey, string $saPasscode)
24
+	{
25
+		$this->client = $client;
26
+		$this->request = new Request($apiKey, $saPasscode);
27
+		$sessionID = $this->createSession();
28
+		Request::setSessionID($sessionID);
29 29
 
30
-    }
31
-    /**
32
-     * Makes API Call to YourMembership
33
-     * @method makeCall
34
-     * @author PA
35
-     * @date   2017-01-10
36
-     * @param  string     $method    Your Membership API Method
37
-     * @param  array      $arguments  Your Membership API Call Arguments
38
-     * @return Response
39
-     */
40
-    public function makeCall(string $method, array $arguments = [])
41
-    {
30
+	}
31
+	/**
32
+	 * Makes API Call to YourMembership
33
+	 * @method makeCall
34
+	 * @author PA
35
+	 * @date   2017-01-10
36
+	 * @param  string     $method    Your Membership API Method
37
+	 * @param  array      $arguments  Your Membership API Call Arguments
38
+	 * @return Response
39
+	 */
40
+	public function makeCall(string $method, array $arguments = [])
41
+	{
42 42
 
43
-        Request::$callId++; //Update the Call ID as they need to be unique per call
44
-        $request = $this->request->buildRequest($method, $arguments);
43
+		Request::$callId++; //Update the Call ID as they need to be unique per call
44
+		$request = $this->request->buildRequest($method, $arguments);
45 45
 
46
-        $response = $this->client->send($request);
46
+		$response = $this->client->send($request);
47 47
 
48
-        return new Response($method, $response);
49
-    }
48
+		return new Response($method, $response);
49
+	}
50 50
 
51
-    /**
52
-     * Creates a new Session with YourMembership
53
-     * @method createSession
54
-     * @author PA
55
-     * @date   2017-01-10
56
-     * @return string        SessionID
57
-     */
58
-    private function createSession() : string
59
-    {
60
-        $response = $this->makeCall('Session.Create')->toObject();
61
-        return $response->SessionID;
51
+	/**
52
+	 * Creates a new Session with YourMembership
53
+	 * @method createSession
54
+	 * @author PA
55
+	 * @date   2017-01-10
56
+	 * @return string        SessionID
57
+	 */
58
+	private function createSession() : string
59
+	{
60
+		$response = $this->makeCall('Session.Create')->toObject();
61
+		return $response->SessionID;
62 62
 
63
-    }
63
+	}
64 64
 
65 65
 }
Please login to merge, or discard this patch.
src/Core/Response.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -8,117 +8,117 @@
 block discarded – undo
8 8
  */
9 9
 class Response
10 10
 {
11
-    private $method;
12
-    private $response;
11
+	private $method;
12
+	private $response;
13 13
 
14
-    public function __construct(string $method, $response)
15
-    {
16
-        $this->method = $method;
14
+	public function __construct(string $method, $response)
15
+	{
16
+		$this->method = $method;
17 17
 
18
-        $body = $response->getBody()->getContents();
19
-        $this->response = new \SimpleXMLElement($body);
18
+		$body = $response->getBody()->getContents();
19
+		$this->response = new \SimpleXMLElement($body);
20 20
 
21
-    }
21
+	}
22 22
 
23
-    /**
24
-     * Checks if the response contains an Error
25
-     * @method hasError
26
-     * @author PA
27
-     * @date   2017-01-10
28
-     * @return bool       hasError
29
-     */
30
-    public function hasError() : bool
31
-    {
32
-        return ($this->getErrorCode() != 0);
33
-    }
23
+	/**
24
+	 * Checks if the response contains an Error
25
+	 * @method hasError
26
+	 * @author PA
27
+	 * @date   2017-01-10
28
+	 * @return bool       hasError
29
+	 */
30
+	public function hasError() : bool
31
+	{
32
+		return ($this->getErrorCode() != 0);
33
+	}
34 34
 
35
-    /**
36
-     * Fetches the Error Code from the Response
37
-     * @method getErrorCode
38
-     * @author PA
39
-     * @date   2017-01-10
40
-     * @return int          Error Code
41
-     */
42
-    public function getErrorCode() : int
43
-    {
44
-        return (int) $this->response->ErrCode;
45
-    }
35
+	/**
36
+	 * Fetches the Error Code from the Response
37
+	 * @method getErrorCode
38
+	 * @author PA
39
+	 * @date   2017-01-10
40
+	 * @return int          Error Code
41
+	 */
42
+	public function getErrorCode() : int
43
+	{
44
+		return (int) $this->response->ErrCode;
45
+	}
46 46
 
47
-    /**
48
-     * Fetches the Error Message From Response
49
-     * @method getError
50
-     * @author PA
51
-     * @date   2017-01-10
52
-     * @return string     Error Message
53
-     */
54
-    public function getError() : string
55
-    {
56
-        return (string) $this->response->ErrDesc;
57
-    }
47
+	/**
48
+	 * Fetches the Error Message From Response
49
+	 * @method getError
50
+	 * @author PA
51
+	 * @date   2017-01-10
52
+	 * @return string     Error Message
53
+	 */
54
+	public function getError() : string
55
+	{
56
+		return (string) $this->response->ErrDesc;
57
+	}
58 58
 
59
-    /**
60
-     * Converts the response to an Array
61
-     * @method toArray
62
-     * @throws YourMembershipException
63
-     * @author PA
64
-     * @date   2017-01-10
65
-     * @return array      Response
66
-     */
67
-    public function toArray() : array
68
-    {
69
-        return $this->unwrapXMLObject(true);
70
-    }
59
+	/**
60
+	 * Converts the response to an Array
61
+	 * @method toArray
62
+	 * @throws YourMembershipException
63
+	 * @author PA
64
+	 * @date   2017-01-10
65
+	 * @return array      Response
66
+	 */
67
+	public function toArray() : array
68
+	{
69
+		return $this->unwrapXMLObject(true);
70
+	}
71 71
 
72
-    /**
73
-     * Converts the response to an Object
74
-     * @method toObject
75
-     * @throws YourMembershipException
76
-     * @author PA
77
-     * @date   2017-01-11
78
-     * @return stdClass  Response
79
-     */
80
-    public function toObject() : \stdClass
81
-    {
82
-        return $this->unwrapXMLObject(false);
83
-    }
72
+	/**
73
+	 * Converts the response to an Object
74
+	 * @method toObject
75
+	 * @throws YourMembershipException
76
+	 * @author PA
77
+	 * @date   2017-01-11
78
+	 * @return stdClass  Response
79
+	 */
80
+	public function toObject() : \stdClass
81
+	{
82
+		return $this->unwrapXMLObject(false);
83
+	}
84 84
 
85
-    /**
86
-     * Unwraps XML Object into either StdClass or Array
87
-     * Lossy conversion, attributes are lost from XML
88
-     *
89
-     * @method unwrapXMLObject
90
-     * @throws YourMembershipException
91
-     * @author PA
92
-     * @date   2017-01-11
93
-     * @param  bool            $asArray unwrap the object into an array instead of object
94
-     * @return mixed|null      Unwrapped Response
95
-     */
96
-    private function unwrapXMLObject(bool $asArray)
97
-    {
98
-        //We cannot unwrap objects that have errors, so throw an exception
99
-        if ($this->hasError()) {
100
-            throw new YourMembershipApiException($this->getError(), $this->getErrorCode(), $this->method);
101
-        }
85
+	/**
86
+	 * Unwraps XML Object into either StdClass or Array
87
+	 * Lossy conversion, attributes are lost from XML
88
+	 *
89
+	 * @method unwrapXMLObject
90
+	 * @throws YourMembershipException
91
+	 * @author PA
92
+	 * @date   2017-01-11
93
+	 * @param  bool            $asArray unwrap the object into an array instead of object
94
+	 * @return mixed|null      Unwrapped Response
95
+	 */
96
+	private function unwrapXMLObject(bool $asArray)
97
+	{
98
+		//We cannot unwrap objects that have errors, so throw an exception
99
+		if ($this->hasError()) {
100
+			throw new YourMembershipApiException($this->getError(), $this->getErrorCode(), $this->method);
101
+		}
102 102
 
103
-        return json_decode(json_encode($this->response->{$this->method}), $asArray);
104
-    }
105
-    /**
106
-     * Returns the Result Count
107
-     * @method getResultCount
108
-     * @author PA
109
-     * @date   2017-01-10
110
-     * @return int|false   false if no ResultCount is present
111
-     */
112
-    public function getResultCount() : int
113
-    {
114
-        $count = false;
103
+		return json_decode(json_encode($this->response->{$this->method}), $asArray);
104
+	}
105
+	/**
106
+	 * Returns the Result Count
107
+	 * @method getResultCount
108
+	 * @author PA
109
+	 * @date   2017-01-10
110
+	 * @return int|false   false if no ResultCount is present
111
+	 */
112
+	public function getResultCount() : int
113
+	{
114
+		$count = false;
115 115
 
116
-        if (isset($this->response->{$this->method}->Results)) {
117
-            $attributes = $this->response->{$this->method}->Results->attributes();
118
-            $count = (int) $attributes['ResultTotal'] ?? false;
119
-        }
116
+		if (isset($this->response->{$this->method}->Results)) {
117
+			$attributes = $this->response->{$this->method}->Results->attributes();
118
+			$count = (int) $attributes['ResultTotal'] ?? false;
119
+		}
120 120
 
121
-        return $count;
122
-    }
121
+		return $count;
122
+	}
123 123
 
124 124
 }
Please login to merge, or discard this patch.
src/config/yourmembership.php 1 patch
Indentation   +11 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,16 +1,15 @@
 block discarded – undo
1 1
  <?php
2
-    /**
3
-     * Your Membership Settings
4
-     *
5
-
6
-     */
2
+	/**
3
+	 * Your Membership Settings
4
+	 *
5
+	 */
7 6
 return [
8
-     /**
9
-      * Default Guzzle Client Settings used by the provider
10
-      */
11
-    'guzzle-client' => [        
12
-            'base_uri' => null,
13
-            'timeout' => 5.0
14
-    ],
7
+	 /**
8
+	  * Default Guzzle Client Settings used by the provider
9
+	  */
10
+	'guzzle-client' => [        
11
+			'base_uri' => null,
12
+			'timeout' => 5.0
13
+	],
15 14
 
16 15
  ]
Please login to merge, or discard this patch.
src/YourMembershipServiceProvider.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 	public function register()
25 25
 	{
26 26
 		$this->mergeConfigFrom(
27
-	    	$this->packageConfigPath, $this->packageName
27
+			$this->packageConfigPath, $this->packageName
28 28
 		);
29 29
 
30 30
 		$this->app->register(YourMembershipClient::class, function($app, $parameters) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 {
9 9
 
10 10
 	private $packageName = 'yourmembership';
11
-	private $packageConfigPath = __DIR__.'/config/yourmembership.php';
11
+	private $packageConfigPath = __DIR__ . '/config/yourmembership.php';
12 12
 	/**
13 13
 	 * Indicates if loading of the provider is deferred.
14 14
 	 *
Please login to merge, or discard this patch.