Completed
Push — master ( 34a003...99eead )
by John
04:04
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/Configuration.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,6 +2,6 @@
 block discarded – undo
2 2
 namespace LunixREST\Configuration;
3 3
 
4 4
 interface Configuration {
5
-	public function get($key);
6
-	public function set($key);
5
+    public function get($key);
6
+    public function set($key);
7 7
 }
Please login to merge, or discard this patch.
Configuration/INIConfiguration.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -9,52 +9,52 @@
 block discarded – undo
9 9
  * @package LunixREST\Configuration
10 10
  */
11 11
 class INIConfiguration implements Configuration {
12
-	/**
13
-	 * @var null
14
-	 */
15
-	protected $nameSpace;
16
-	/**
17
-	 * @var
18
-	 */
19
-	protected $filename;
20
-
21
-	/**
22
-	 * @param string $filename
23
-	 * @param string $nameSpace
24
-	 */
25
-	public function __construct($filename, $nameSpace = null){
26
-		$this->filename = $filename;
27
-		$this->nameSpace = $nameSpace;
28
-	}
29
-
30
-	/**
31
-	 * @param $key
32
-	 * @return mixed
33
-	 * @throws INIKeyNotFoundException
34
-	 * @throws INIParseException
35
-	 */
36
-	public function get($key){
37
-		$config = parse_ini_file($this->filename, (bool)$this->nameSpace);
38
-
39
-		if($config === false){
40
-			throw new INIParseException('Could not parse: ' . $this->filename, true);
41
-		}
42
-
43
-		if($this->nameSpace) {
44
-			if(isset($config[$this->nameSpace])) {
45
-				$config = $config[$this->nameSpace];
46
-			} else {
47
-				throw new INIKeyNotFoundException();
48
-			}
49
-		}
50
-
51
-		return isset($config[$key]) ? $config[$key] : null;
52
-	}
53
-
54
-	/**
55
-	 * @param $key
56
-	 */
57
-	public function set($key){
58
-		//TODO write this
59
-	}
12
+    /**
13
+     * @var null
14
+     */
15
+    protected $nameSpace;
16
+    /**
17
+     * @var
18
+     */
19
+    protected $filename;
20
+
21
+    /**
22
+     * @param string $filename
23
+     * @param string $nameSpace
24
+     */
25
+    public function __construct($filename, $nameSpace = null){
26
+        $this->filename = $filename;
27
+        $this->nameSpace = $nameSpace;
28
+    }
29
+
30
+    /**
31
+     * @param $key
32
+     * @return mixed
33
+     * @throws INIKeyNotFoundException
34
+     * @throws INIParseException
35
+     */
36
+    public function get($key){
37
+        $config = parse_ini_file($this->filename, (bool)$this->nameSpace);
38
+
39
+        if($config === false){
40
+            throw new INIParseException('Could not parse: ' . $this->filename, true);
41
+        }
42
+
43
+        if($this->nameSpace) {
44
+            if(isset($config[$this->nameSpace])) {
45
+                $config = $config[$this->nameSpace];
46
+            } else {
47
+                throw new INIKeyNotFoundException();
48
+            }
49
+        }
50
+
51
+        return isset($config[$key]) ? $config[$key] : null;
52
+    }
53
+
54
+    /**
55
+     * @param $key
56
+     */
57
+    public function set($key){
58
+        //TODO write this
59
+    }
60 60
 }
Please login to merge, or discard this 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.
Endpoints/EndPoint.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,56 +17,56 @@  discard block
 block discarded – undo
17 17
     /**
18 18
      * @param Request $request
19 19
      */
20
-    public function __construct(Request $request){
20
+    public function __construct(Request $request) {
21 21
         $this->request = $request;
22 22
     }
23 23
 
24 24
     /**
25 25
      * @return array
26 26
      */
27
-    public function get(){
27
+    public function get() {
28 28
         $this->unsupportedMethod();
29 29
     }
30 30
 
31 31
     /**
32 32
      * @return array
33 33
      */
34
-    public function getAll(){
34
+    public function getAll() {
35 35
         $this->unsupportedMethod();
36 36
     }
37 37
 
38 38
     /**
39 39
      * @return array
40 40
      */
41
-    public function post(){
41
+    public function post() {
42 42
         $this->unsupportedMethod();
43 43
     }
44 44
 
45 45
     /**
46 46
      * @return array
47 47
      */
48
-    public function postAll(){
48
+    public function postAll() {
49 49
         $this->unsupportedMethod();
50 50
     }
51 51
 
52 52
     /**
53 53
      * @return array
54 54
      */
55
-    public function put(){
55
+    public function put() {
56 56
         $this->unsupportedMethod();
57 57
     }
58 58
 
59 59
     /**
60 60
      * @return array
61 61
      */
62
-    public function putAll(){
62
+    public function putAll() {
63 63
         $this->unsupportedMethod();
64 64
     }
65 65
 
66 66
     /**
67 67
      * @return array
68 68
      */
69
-    public function options(){
69
+    public function options() {
70 70
         $this->unsupportedMethod();
71 71
     }
72 72
 
@@ -74,25 +74,25 @@  discard block
 block discarded – undo
74 74
     /**
75 75
      * @return array
76 76
      */
77
-    public function optionsAll(){
77
+    public function optionsAll() {
78 78
         $this->unsupportedMethod();
79 79
     }
80 80
 
81 81
     /**
82 82
      * @return array
83 83
      */
84
-    public function delete(){
84
+    public function delete() {
85 85
         $this->unsupportedMethod();
86 86
     }
87 87
 
88 88
     /**
89 89
      * @return array
90 90
      */
91
-    public function deleteAll(){
91
+    public function deleteAll() {
92 92
         $this->unsupportedMethod();
93 93
     }
94 94
 
95
-    private function unsupportedMethod(){
95
+    private function unsupportedMethod() {
96 96
         throw new UnknownEndpointException('Method not supported');
97 97
     }
98 98
 }
Please login to merge, or discard this patch.
Request/Request.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -59,19 +59,19 @@  discard block
 block discarded – undo
59 59
      * @param string $instance
60 60
      * @throws InvalidRequestFormatException
61 61
      */
62
-    public function __construct($method, array $headers, array $data, $ip, $url, $version = '', $apiKey = '', $endpoint = '', $extension = '', $instance = ''){
62
+    public function __construct($method, array $headers, array $data, $ip, $url, $version = '', $apiKey = '', $endpoint = '', $extension = '', $instance = '') {
63 63
         $this->method = strtolower($method);
64 64
         $this->headers = $headers;
65 65
         $this->data = $data;
66 66
         $this->ip = $ip;
67 67
 
68
-        if($version && $apiKey && $endpoint && $extension){
68
+        if ($version && $apiKey && $endpoint && $extension) {
69 69
             $this->version = $version;
70 70
             $this->apiKey = $apiKey;
71 71
             $this->endpoint = $endpoint;
72 72
             $this->extension = $extension;
73 73
             $this->instance = $instance;
74
-        } elseif($url !== false) {
74
+        } elseif ($url !== false) {
75 75
             $this->parseURL($url);
76 76
         } else {
77 77
             throw new InvalidRequestFormatException('Either URL or the rest of the parameters MUST be set');
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
      * @param string $url
155 155
      * @throws InvalidRequestFormatException
156 156
      */
157
-    private function parseURL($url){
157
+    private function parseURL($url) {
158 158
         $splitURL = explode('/', trim($url, '/'));
159
-        if(count($splitURL) < 3){
159
+        if (count($splitURL) < 3) {
160 160
             throw new InvalidRequestFormatException();
161 161
         }
162 162
         //Find endpoint
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         $splitExtension = explode('.', $splitURL[count($splitURL) - 1]);
168 168
         $this->extension = array_pop($splitExtension);
169 169
 
170
-        if(count($splitURL) == 4){
170
+        if (count($splitURL) == 4) {
171 171
             $this->instance = implode('.', $splitExtension);
172 172
         } else {
173 173
             $this->endpoint = implode('.', $splitExtension);
Please login to merge, or discard this patch.