Passed
Push — master ( e71961...c8cbb8 )
by Justin
04:01
created
system/packages/com.jukusoft.cms.apimethods/classes/apimethod.php 2 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -18,94 +18,94 @@
 block discarded – undo
18 18
 
19 19
 class ApiMethod {
20 20
 
21
-	protected $apimethods = array();
22
-	protected $method = array();
21
+    protected $apimethods = array();
22
+    protected $method = array();
23 23
 
24
-	public function __construct () {
25
-		//
26
-	}
24
+    public function __construct () {
25
+        //
26
+    }
27 27
 
28
-	public function loadApiMethods () {
28
+    public function loadApiMethods () {
29 29
 
30
-		if (Cache::contains("apimethods", "apimethods")) {
31
-			$this->apimethods = Cache::get("apimethods", "apimethods");
32
-		} else {
33
-			$rows = (Array) DataBase::getInstance()->listRows("SELECT * FROM `{praefix}api_methods` WHERE `activated` = '1'; ");
30
+        if (Cache::contains("apimethods", "apimethods")) {
31
+            $this->apimethods = Cache::get("apimethods", "apimethods");
32
+        } else {
33
+            $rows = (Array) DataBase::getInstance()->listRows("SELECT * FROM `{praefix}api_methods` WHERE `activated` = '1'; ");
34 34
 
35
-			foreach ($rows as $row) {
36
-				$row = (Array) $row;
37
-				$this->apimethods[$row['api_method']] = $row;
38
-			}
35
+            foreach ($rows as $row) {
36
+                $row = (Array) $row;
37
+                $this->apimethods[$row['api_method']] = $row;
38
+            }
39 39
 
40
-			Cache::put("apimethods", "apimethods", $this->apimethods);
41
-		}
40
+            Cache::put("apimethods", "apimethods", $this->apimethods);
41
+        }
42 42
 
43
-	}
43
+    }
44 44
 
45
-	public function loadMethod ($method) {
46
-		if (isset($this->apimethods[$method])) {
47
-			$this->method = $this->apimethods[$method];
48
-		}
49
-	}
45
+    public function loadMethod ($method) {
46
+        if (isset($this->apimethods[$method])) {
47
+            $this->method = $this->apimethods[$method];
48
+        }
49
+    }
50 50
 
51
-	public function executeApiMethod () {
51
+    public function executeApiMethod () {
52 52
 
53
-		if (!$this->method) {
54
-			exit;
55
-		}
53
+        if (!$this->method) {
54
+            exit;
55
+        }
56 56
 
57
-		if ($this->method['response_type'] != "specific") {
58
-			header("Content-Type: " . $this->method['response_type']);
59
-		}
57
+        if ($this->method['response_type'] != "specific") {
58
+            header("Content-Type: " . $this->method['response_type']);
59
+        }
60 60
 
61
-		$classname = $this->method['classname'];
62
-		$method = $this->method['method'];
61
+        $classname = $this->method['classname'];
62
+        $method = $this->method['method'];
63 63
 
64
-		$args = array();
65
-		Events::throwEvent("apimethods", array('method' => $this->method, 'args' => &$args));
64
+        $args = array();
65
+        Events::throwEvent("apimethods", array('method' => $this->method, 'args' => &$args));
66 66
 
67
-		$result = call_user_func(array($classname, $method), $args);
67
+        $result = call_user_func(array($classname, $method), $args);
68 68
 
69
-		echo $result;
70
-	}
69
+        echo $result;
70
+    }
71 71
 
72
-	public static function addMethod (string $api_method, string $class_name, string $method, string $owner = "system", string $response_type = "") {
73
-		//add method to database
74
-		Database::getInstance()->execute("INSERT INTO `{praefix}api_methods` (
72
+    public static function addMethod (string $api_method, string $class_name, string $method, string $owner = "system", string $response_type = "") {
73
+        //add method to database
74
+        Database::getInstance()->execute("INSERT INTO `{praefix}api_methods` (
75 75
 			`api_method`, `classname`, `method`, `response_type`, `owner`, `activated`
76 76
 		) VALUES (
77 77
 			:api_method, :class_name, :method, :response_type, :owner, '1'
78 78
 		) ON DUPLICATE KEY UPDATE `classname` = :class_name, `method` = :method, `response_type` = :response_type, `owner` = :owner, `activated` = '1'; ", array(
79
-			'api_method' => $api_method,
80
-			'class_name' => $class_name,
81
-			'method' => $method,
82
-			'response_type' => $response_type,
83
-			'owner' => $owner
84
-		));
85
-
86
-		//clear cache
87
-		Cache::clear("apimethods");
88
-	}
89
-
90
-	public static function deleteMethod (string $api_method) {
91
-		//delete from database
92
-		Database::getInstance()->execute("DELETE FROM `{praefix}api_methods` WHERE `api_method` = :api_method; ", array(
93
-			'api_method' => $api_method
94
-		));
95
-
96
-		//clear cache
97
-		Cache::clear("apimethods");
98
-	}
99
-
100
-	public static function deleteMethodsByOwner (string $owner) {
101
-		//delete from database
102
-		Database::getInstance()->execute("DELETE FROM `{praefix}api_methods` WHERE `owner` = :owner; ", array(
103
-			'owner' => $owner
104
-		));
105
-
106
-		//clear cache
107
-		Cache::clear("apimethods");
108
-	}
79
+            'api_method' => $api_method,
80
+            'class_name' => $class_name,
81
+            'method' => $method,
82
+            'response_type' => $response_type,
83
+            'owner' => $owner
84
+        ));
85
+
86
+        //clear cache
87
+        Cache::clear("apimethods");
88
+    }
89
+
90
+    public static function deleteMethod (string $api_method) {
91
+        //delete from database
92
+        Database::getInstance()->execute("DELETE FROM `{praefix}api_methods` WHERE `api_method` = :api_method; ", array(
93
+            'api_method' => $api_method
94
+        ));
95
+
96
+        //clear cache
97
+        Cache::clear("apimethods");
98
+    }
99
+
100
+    public static function deleteMethodsByOwner (string $owner) {
101
+        //delete from database
102
+        Database::getInstance()->execute("DELETE FROM `{praefix}api_methods` WHERE `owner` = :owner; ", array(
103
+            'owner' => $owner
104
+        ));
105
+
106
+        //clear cache
107
+        Cache::clear("apimethods");
108
+    }
109 109
 
110 110
 }
111 111
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
 	protected $apimethods = array();
22 22
 	protected $method = array();
23 23
 
24
-	public function __construct () {
24
+	public function __construct() {
25 25
 		//
26 26
 	}
27 27
 
28
-	public function loadApiMethods () {
28
+	public function loadApiMethods() {
29 29
 
30 30
 		if (Cache::contains("apimethods", "apimethods")) {
31 31
 			$this->apimethods = Cache::get("apimethods", "apimethods");
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
 
43 43
 	}
44 44
 
45
-	public function loadMethod ($method) {
45
+	public function loadMethod($method) {
46 46
 		if (isset($this->apimethods[$method])) {
47 47
 			$this->method = $this->apimethods[$method];
48 48
 		}
49 49
 	}
50 50
 
51
-	public function executeApiMethod () {
51
+	public function executeApiMethod() {
52 52
 
53 53
 		if (!$this->method) {
54 54
 			exit;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		echo $result;
70 70
 	}
71 71
 
72
-	public static function addMethod (string $api_method, string $class_name, string $method, string $owner = "system", string $response_type = "") {
72
+	public static function addMethod(string $api_method, string $class_name, string $method, string $owner = "system", string $response_type = "") {
73 73
 		//add method to database
74 74
 		Database::getInstance()->execute("INSERT INTO `{praefix}api_methods` (
75 75
 			`api_method`, `classname`, `method`, `response_type`, `owner`, `activated`
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		Cache::clear("apimethods");
88 88
 	}
89 89
 
90
-	public static function deleteMethod (string $api_method) {
90
+	public static function deleteMethod(string $api_method) {
91 91
 		//delete from database
92 92
 		Database::getInstance()->execute("DELETE FROM `{praefix}api_methods` WHERE `api_method` = :api_method; ", array(
93 93
 			'api_method' => $api_method
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		Cache::clear("apimethods");
98 98
 	}
99 99
 
100
-	public static function deleteMethodsByOwner (string $owner) {
100
+	public static function deleteMethodsByOwner(string $owner) {
101 101
 		//delete from database
102 102
 		Database::getInstance()->execute("DELETE FROM `{praefix}api_methods` WHERE `owner` = :owner; ", array(
103 103
 			'owner' => $owner
Please login to merge, or discard this patch.