Completed
Branch master (51d2f6)
by John
02:24
created
AccessControl/AllAccessConfigurationListAccessControl.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      * @param Configuration $config a config that has a list of valid keys in the stored $configKey
23 23
      * @param string $configKey key to use when accessing the list of valid keys from the $config
24 24
      */
25
-    public function __construct(Configuration $config, $configKey = 'keys'){
25
+    public function __construct(Configuration $config, $configKey = 'keys') {
26 26
         $this->config = $config;
27 27
         $this->configKey = $configKey;
28 28
     }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      * @param \LunixREST\Request\Request $request
32 32
      * @return bool true if this key is valid
33 33
      */
34
-    public function validateAccess(Request $request){
34
+    public function validateAccess(Request $request) {
35 35
         return $this->validateKey($request->getApiKey());
36 36
     }
37 37
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      * @param $apiKey
40 40
      * @return bool true if the key is found inside of the array returned by the config when $config->get is called with the key from the constructor
41 41
      */
42
-    public function validateKey($apiKey){
42
+    public function validateKey($apiKey) {
43 43
         return in_array($apiKey, $this->config->get($this->configKey));
44 44
     }
45 45
 }
46 46
\ No newline at end of file
Please login to merge, or discard this patch.
AccessControl/AllAccessListAccessControl.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     /**
16 16
      * @param array $keys
17 17
      */
18
-    public function __construct(Array $keys){
18
+    public function __construct(Array $keys) {
19 19
         $this->keys = $keys;
20 20
     }
21 21
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      * @param \LunixREST\Request\Request $request
24 24
      * @return bool true if key is valid
25 25
      */
26
-    public function validateAccess(Request $request){
26
+    public function validateAccess(Request $request) {
27 27
         return $this->validateKey($request->getApiKey());
28 28
     }
29 29
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      * @param $apiKey
32 32
      * @return bool true if key is in the array passed to this object in it's construction
33 33
      */
34
-    public function validateKey($apiKey){
34
+    public function validateKey($apiKey) {
35 35
         return in_array($apiKey, $this->keys);
36 36
     }
37 37
 }
38 38
\ No newline at end of file
Please login to merge, or discard this patch.
AccessControl/MultiAccessControl.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     /**
16 16
      * @param AccessControl[] $accessControls array of access controls to use based on implmentation
17 17
      */
18
-    public function __construct(array $accessControls){
18
+    public function __construct(array $accessControls) {
19 19
         $this->accessControls = $accessControls;
20 20
     }
21 21
 }
22 22
\ No newline at end of file
Please login to merge, or discard this patch.
AccessControl/MultiAndAccessControl.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
      * @param \LunixREST\Request\Request $request
12 12
      * @return bool true if all of the $accessControls' validate access methods returned true for the given request
13 13
      */
14
-    public function validateAccess(Request $request){
15
-        foreach($this->accessControls as $accessControl){
16
-            if(!$accessControl->validateAccess($request)){
14
+    public function validateAccess(Request $request) {
15
+        foreach ($this->accessControls as $accessControl) {
16
+            if (!$accessControl->validateAccess($request)) {
17 17
                 return false;
18 18
             }
19 19
         }
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
      * @param $apiKey
25 25
      * @return bool true if all of the $accessControls' validate key methods returned true for the given request
26 26
      */
27
-    public function validateKey($apiKey){
28
-        foreach($this->accessControls as $accessControl){
29
-            if(!$accessControl->validateKey($apiKey)){
27
+    public function validateKey($apiKey) {
28
+        foreach ($this->accessControls as $accessControl) {
29
+            if (!$accessControl->validateKey($apiKey)) {
30 30
                 return false;
31 31
             }
32 32
         }
Please login to merge, or discard this patch.
AccessControl/PublicAccessControl.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     /**
16 16
      * @param string $publicKey
17 17
      */
18
-    public function __construct($publicKey = 'public'){
18
+    public function __construct($publicKey = 'public') {
19 19
         $this->publicKey = $publicKey;
20 20
     }
21 21
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      * @param \LunixREST\Request\Request $request
24 24
      * @return bool true if key is valid
25 25
      */
26
-    public function validateAccess(Request $request){
26
+    public function validateAccess(Request $request) {
27 27
         return $this->validateKey($request->getApiKey());
28 28
     }
29 29
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      * @param $apiKey
32 32
      * @return bool true if key is the key specified in the constructor
33 33
      */
34
-    public function validateKey($apiKey){
34
+    public function validateKey($apiKey) {
35 35
         return $apiKey === $this->publicKey;
36 36
     }
37 37
 }
38 38
\ No newline at end of file
Please login to merge, or discard this patch.
Configuration/INIConfiguration.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * @param string $filename
23 23
 	 * @param string $nameSpace
24 24
 	 */
25
-	public function __construct($filename, $nameSpace = null){
25
+	public function __construct($filename, $nameSpace = null) {
26 26
 		$this->filename = $filename;
27 27
 		$this->nameSpace = $nameSpace;
28 28
 	}
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 	 * @throws INIKeyNotFoundException
34 34
 	 * @throws INIParseException
35 35
 	 */
36
-	public function get($key){
37
-		$config = parse_ini_file($this->filename, (bool)$this->nameSpace);
36
+	public function get($key) {
37
+		$config = parse_ini_file($this->filename, (bool) $this->nameSpace);
38 38
 
39
-		if($config === false){
39
+		if ($config === false) {
40 40
 			throw new INIParseException('Could not parse: ' . $this->filename, true);
41 41
 		}
42 42
 
43
-		if($this->nameSpace) {
44
-			if(isset($config[$this->nameSpace])) {
43
+		if ($this->nameSpace) {
44
+			if (isset($config[$this->nameSpace])) {
45 45
 				$config = $config[$this->nameSpace];
46 46
 			} else {
47 47
 				throw new INIKeyNotFoundException();
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	/**
55 55
 	 * @param $key
56 56
 	 */
57
-	public function set($key){
57
+	public function set($key) {
58 58
 		//TODO write this
59 59
 	}
60 60
 }
Please login to merge, or discard this patch.
Response/JSONResponse.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
     /**
10 10
      * @return string
11 11
      */
12
-    public function output(){
12
+    public function output() {
13 13
         return json_encode($this->data);
14 14
     }
15 15
 }
Please login to merge, or discard this patch.
Response/Response.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
     /**
15 15
      * @param array $data
16 16
      */
17
-    public function __construct(array $data){
17
+    public function __construct(array $data) {
18 18
         $this->data = $data;
19 19
     }
20 20
 
Please login to merge, or discard this patch.
Router/Router.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      * @param Configuration $formatsConfig
46 46
      * @param string $endpointNamespace
47 47
      */
48
-    public function __construct(AccessControl $accessControl, Throttle $throttle, Configuration $formatsConfig, $endpointNamespace = ''){
48
+    public function __construct(AccessControl $accessControl, Throttle $throttle, Configuration $formatsConfig, $endpointNamespace = '') {
49 49
         $this->accessControl = $accessControl;
50 50
         $this->throttle = $throttle;
51 51
         $this->formatsConfig = $formatsConfig;
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      * @throws UnknownEndpointException
63 63
      * @throws UnknownResponseFormatException
64 64
      */
65
-    public function handle(Request $request){
65
+    public function handle(Request $request) {
66 66
         $this->validateKey($request);
67 67
 
68 68
         $this->validateExtension($request);
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      * @param Request $request
91 91
      * @return string
92 92
      */
93
-    private function endpointClass(Request $request){
93
+    private function endpointClass(Request $request) {
94 94
         return '\\' . $this->endpointNamespace . '\Endpoints\v' . str_replace('.', '_', $request->getVersion()) . '\\' . $request->getEndpoint();
95 95
     }
96 96
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      * @param Request $request
99 99
      * @return string
100 100
      */
101
-    private function responseClass(Request $request){
101
+    private function responseClass(Request $request) {
102 102
         return '\\LunixREST\\Response\\' . strtoupper($request->getExtension()) . "Response";
103 103
     }
104 104
 
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
      * @param Request $request
107 107
      * @throws InvalidAPIKeyException
108 108
      */
109
-    private function validateKey(Request $request){
110
-        if(!$this->accessControl->validateKey($request->getApiKey())){
109
+    private function validateKey(Request $request) {
110
+        if (!$this->accessControl->validateKey($request->getApiKey())) {
111 111
             throw new InvalidAPIKeyException('Invalid API key');
112 112
         }
113 113
     }
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
     private function validateExtension(Request $request)
121 121
     {
122 122
         $formats = $this->formatsConfig->get('formats');
123
-        if(!($formats && in_array($request->getExtension(), $formats))){
124
-            throw new UnknownResponseFormatException('Unknown response format: ' .$request->getExtension());
123
+        if (!($formats && in_array($request->getExtension(), $formats))) {
124
+            throw new UnknownResponseFormatException('Unknown response format: ' . $request->getExtension());
125 125
         }
126 126
     }
127 127
 
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
      * @param $fullEndpoint
130 130
      * @throws UnknownEndpointException
131 131
      */
132
-    private function validateEndpoint($fullEndpoint){
132
+    private function validateEndpoint($fullEndpoint) {
133 133
         $endpointReflection = new \ReflectionClass($fullEndpoint);
134
-        if(!class_exists($fullEndpoint) || !$endpointReflection->isSubclassOf('\LunixREST\Endpoints\Endpoint')){
134
+        if (!class_exists($fullEndpoint) || !$endpointReflection->isSubclassOf('\LunixREST\Endpoints\Endpoint')) {
135 135
             throw new UnknownEndpointException("unknown endpoint: " . $fullEndpoint);
136 136
         }
137 137
     }
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
      * @param Request $request
141 141
      * @throws ThrottleLimitExceededException
142 142
      */
143
-    private function throttle(Request $request){
144
-        if($this->throttle->throttle($request)){
143
+    private function throttle(Request $request) {
144
+        if ($this->throttle->throttle($request)) {
145 145
             throw new ThrottleLimitExceededException('Request limit exceeded');
146 146
         }
147 147
     }
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
      * @param Request $request
151 151
      * @throws AccessDeniedException
152 152
      */
153
-    private function validateAccess(Request $request){
154
-        if(!$this->accessControl->validateAccess($request)){
153
+    private function validateAccess(Request $request) {
154
+        if (!$this->accessControl->validateAccess($request)) {
155 155
             throw new AccessDeniedException("API key does not have the required permissions to access requested resource");
156 156
         }
157 157
     }
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
      * @param $responseData
161 161
      * @throws InvalidResponseFormatException
162 162
      */
163
-    private function validateResponse($responseData){
164
-        if(!is_array($responseData)){
163
+    private function validateResponse($responseData) {
164
+        if (!is_array($responseData)) {
165 165
             throw new InvalidResponseFormatException('Method output MUST be an array');
166 166
         }
167 167
     }
Please login to merge, or discard this patch.