Completed
Push — master ( 221395...658920 )
by Andrey
02:54
created
Uri.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -5,28 +5,28 @@
 block discarded – undo
5 5
 
6 6
     private $requestUri = '';
7 7
 
8
-    public function __construct(){
8
+    public function __construct() {
9 9
         $this->requestUri = $_SERVER['REQUEST_URI'];
10
-        $tmp = explode('/',$this->requiestUri);
11
-        foreach($tmp as $key=>$value){
10
+        $tmp = explode('/', $this->requiestUri);
11
+        foreach ($tmp as $key=>$value) {
12 12
             $value = trim($value);
13
-            if(empty($value)) unset($tmp[$key]);
13
+            if (empty($value)) unset($tmp[$key]);
14 14
             else $tmp[$key] = $value;
15 15
         }
16 16
         $tmp = array_values($tmp);
17 17
         $this->requestUri = $tmp;
18 18
     }
19 19
 
20
-    public function full(){
21
-        return '/'.implode('/',$this->requestUri);
20
+    public function full() {
21
+        return '/'.implode('/', $this->requestUri);
22 22
     }
23 23
 
24
-    public function part($number){
25
-        if(isset($this->requestUri[$number])) return (string) urldecode($this->requestUri[$number]);
24
+    public function part($number) {
25
+        if (isset($this->requestUri[$number])) return (string) urldecode($this->requestUri[$number]);
26 26
         else return '';
27 27
     }
28 28
 
29
-    public function host(){
29
+    public function host() {
30 30
         return parse_url('http://'.$_SERVER['HTTP_HOST'])['host']
31 31
     }
32 32
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,8 +10,11 @@  discard block
 block discarded – undo
10 10
         $tmp = explode('/',$this->requiestUri);
11 11
         foreach($tmp as $key=>$value){
12 12
             $value = trim($value);
13
-            if(empty($value)) unset($tmp[$key]);
14
-            else $tmp[$key] = $value;
13
+            if(empty($value)) {
14
+                unset($tmp[$key]);
15
+            } else {
16
+                $tmp[$key] = $value;
17
+            }
15 18
         }
16 19
         $tmp = array_values($tmp);
17 20
         $this->requestUri = $tmp;
@@ -22,8 +25,11 @@  discard block
 block discarded – undo
22 25
     }
23 26
 
24 27
     public function part($number){
25
-        if(isset($this->requestUri[$number])) return (string) urldecode($this->requestUri[$number]);
26
-        else return '';
28
+        if(isset($this->requestUri[$number])) {
29
+            return (string) urldecode($this->requestUri[$number]);
30
+        } else {
31
+            return '';
32
+        }
27 33
     }
28 34
 
29 35
     public function host(){
Please login to merge, or discard this patch.
Content.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     private static $keywords;
17 17
     private static $uri;
18 18
 
19
-    public function __construct(){
19
+    public function __construct() {
20 20
         # Config
21 21
         self::$config = (new Config)->get();
22 22
         # Application
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
         self::$uri = new Uri;
40 40
     }
41 41
 
42
-    public function view($name){
42
+    public function view($name) {
43 43
         $file = $this->file($name);
44
-        if(is_file($file)) require $file;
44
+        if (is_file($file)) require $file;
45 45
     }
46 46
 
47
-    public function page(){
47
+    public function page() {
48 48
         # get file
49 49
         $file = $this->file();
50 50
         # get content
@@ -62,46 +62,46 @@  discard block
 block discarded – undo
62 62
         # get keywords
63 63
         $keywords = self::$keywords->get();
64 64
         # include for page
65
-        $content = preg_replace('/<head>/',"<head>$keywords",$content);
66
-        $content = preg_replace('/<head>/',"<head>$description",$content);
67
-        $content = preg_replace('/<head>/',"<head>$title",$content);
68
-        $content = preg_replace('/<\/head>/',"$css</head>",$content);
69
-        $content = preg_replace('/<\/body>/',"$js</body>",$content);
65
+        $content = preg_replace('/<head>/', "<head>$keywords", $content);
66
+        $content = preg_replace('/<head>/', "<head>$description", $content);
67
+        $content = preg_replace('/<head>/', "<head>$title", $content);
68
+        $content = preg_replace('/<\/head>/', "$css</head>", $content);
69
+        $content = preg_replace('/<\/body>/', "$js</body>", $content);
70 70
         $minify = new MinifyHTML($content);
71 71
         $content = $minify->compress();
72 72
         echo $content;
73 73
     }
74 74
 
75
-    public function js($query){
75
+    public function js($query) {
76 76
         echo self::$js->compile($query);
77 77
     }
78 78
 
79 79
     # $type - page,view
80
-    public function file($name=false){
81
-        if($name === false){
80
+    public function file($name = false) {
81
+        if ($name === false) {
82 82
             $path = self::$config['core']['page'];
83 83
         } else {
84 84
             $path = self::$config['core']['view'].'/'.$name;
85 85
         }
86 86
         # Route
87 87
         $uri = self::$path;
88
-        array_push($uri,'');
89
-        foreach($uri as $key=>$value){ if(empty(trim($value))) { unset($uri[$key]); continue; } }
88
+        array_push($uri, '');
89
+        foreach ($uri as $key=>$value) { if (empty(trim($value))) { unset($uri[$key]); continue; } }
90 90
         $uri = array_values($uri);
91 91
         $isFile = null;
92 92
         $currentUri = null;
93 93
         $filePhtml = null;
94
-        for($i=count($uri)-1; $i>=0; $i--){
95
-          $nextUri = implode('/',array_slice($uri,0,$i+1));
96
-          $getFile = function($type) use($path,$nextUri){
94
+        for ($i = count($uri)-1; $i>=0; $i--) {
95
+          $nextUri = implode('/', array_slice($uri, 0, $i+1));
96
+          $getFile = function($type) use($path, $nextUri){
97 97
             $file = $path.'/'.$nextUri.'/index.'.$type;
98
-            if(is_file($file)) return $file;
98
+            if (is_file($file)) return $file;
99 99
             return null;
100 100
           };
101 101
           $filePhtml = $getFile('phtml');
102
-          if($filePhtml) { $currentUri = $nextUri; break; }
102
+          if ($filePhtml) { $currentUri = $nextUri; break; }
103 103
         }
104
-        if($filePhtml === null) {
104
+        if ($filePhtml === null) {
105 105
           $filePhtml = $path.'/index.phtml';
106 106
         }
107 107
         return $filePhtml;
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,7 +41,9 @@  discard block
 block discarded – undo
41 41
 
42 42
     public function view($name){
43 43
         $file = $this->file($name);
44
-        if(is_file($file)) require $file;
44
+        if(is_file($file)) {
45
+            require $file;
46
+        }
45 47
     }
46 48
 
47 49
     public function page(){
@@ -95,7 +97,9 @@  discard block
 block discarded – undo
95 97
           $nextUri = implode('/',array_slice($uri,0,$i+1));
96 98
           $getFile = function($type) use($path,$nextUri){
97 99
             $file = $path.'/'.$nextUri.'/index.'.$type;
98
-            if(is_file($file)) return $file;
100
+            if(is_file($file)) {
101
+                return $file;
102
+            }
99 103
             return null;
100 104
           };
101 105
           $filePhtml = $getFile('phtml');
Please login to merge, or discard this patch.