@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | public $headers; |
10 | 10 | public $body; |
11 | 11 | |
12 | - public function __construct($url, $htmx = false, $parse = true, $code = 302, $redirect_after = null ) |
|
12 | + public function __construct($url, $htmx = false, $parse = true, $code = 302, $redirect_after = null) |
|
13 | 13 | { |
14 | 14 | if ($this->isLocalUrl($url) && $parse) { |
15 | 15 | $parsedUrl = Application::getDir()."/".$url; |
@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | if ($htmx) { |
20 | 20 | $headers = ["HX-Redirect" => $parsedUrl]; |
21 | 21 | } else { |
22 | - $headers = [ "Location" => $parsedUrl ]; |
|
22 | + $headers = ["Location" => $parsedUrl]; |
|
23 | 23 | } |
24 | - if(isset($redirect_after)){ |
|
24 | + if (isset($redirect_after)) { |
|
25 | 25 | $_SESSION["redirect_url"] = $redirect_after; |
26 | 26 | |
27 | 27 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | } else { |
22 | 22 | $headers = [ "Location" => $parsedUrl ]; |
23 | 23 | } |
24 | - if(isset($redirect_after)){ |
|
24 | + if(isset($redirect_after)) { |
|
25 | 25 | $_SESSION["redirect_url"] = $redirect_after; |
26 | 26 | |
27 | 27 | } |
@@ -13,13 +13,13 @@ |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | |
16 | - public function sendHeaders(){ |
|
16 | + public function sendHeaders() { |
|
17 | 17 | foreach ($this->headers as $key => $value) { |
18 | 18 | header("$key: $value"); |
19 | 19 | } |
20 | 20 | } |
21 | 21 | |
22 | - public function sendBody(){ |
|
22 | + public function sendBody() { |
|
23 | 23 | echo $this->body; |
24 | 24 | } |
25 | 25 |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace Lepton\Http\Response; |
4 | 4 | |
5 | - class NotFoundResponse extends HttpResponse |
|
5 | + class NotFoundResponse extends HttpResponse |
|
6 | 6 | { |
7 | 7 | |
8 | 8 | public function __construct( |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace Lepton\Http\Response; |
4 | 4 | |
5 | - class InternalErrorResponse extends HttpResponse |
|
5 | + class InternalErrorResponse extends HttpResponse |
|
6 | 6 | { |
7 | 7 | |
8 | 8 | public function __construct( |
@@ -50,7 +50,7 @@ |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | public function handle($match): FileResponse|NotFoundResponse{ |
53 | - if($match instanceof Match404){ |
|
53 | + if($match instanceof Match404) { |
|
54 | 54 | return new NotFoundResponse(); |
55 | 55 | } |
56 | 56 | return new FileResponse($match->filePath, $match->contentType); |
@@ -52,14 +52,14 @@ |
||
52 | 52 | return new MatchFile(filePath: $filePath, contentType: $contentType); |
53 | 53 | } else { |
54 | 54 | die($filePath); |
55 | - return new Match404(); |
|
55 | + return new Match404(); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | 59 | public function handle($match): FileResponse|NotFoundResponse{ |
60 | - if($match instanceof Match404){ |
|
60 | + if($match instanceof Match404){ |
|
61 | 61 | return new NotFoundResponse(); |
62 | - } |
|
63 | - return new FileResponse($match->filePath, $match->contentType); |
|
62 | + } |
|
63 | + return new FileResponse($match->filePath, $match->contentType); |
|
64 | 64 | } |
65 | 65 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | $root = Application::$documentRoot; |
19 | 19 | $root .= Application::getAppConfig()->base_url; |
20 | - $filePath = $root."/".Application::getAppConfig()->static_files_dir. "/". $url; |
|
20 | + $filePath = $root."/".Application::getAppConfig()->static_files_dir."/".$url; |
|
21 | 21 | |
22 | 22 | // Check if the file exists |
23 | 23 | if (file_exists($filePath)) { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | public function handle($match): FileResponse|NotFoundResponse{ |
60 | - if($match instanceof Match404){ |
|
60 | + if ($match instanceof Match404) { |
|
61 | 61 | return new NotFoundResponse(); |
62 | 62 | } |
63 | 63 | return new FileResponse($match->filePath, $match->contentType); |
@@ -60,7 +60,7 @@ |
||
60 | 60 | $middlewareInstance->addMatcher($matcher); |
61 | 61 | $middlewareInstance->setRequest($this->request); |
62 | 62 | $middlewareResult = $middlewareInstance(...$args); |
63 | - if($middlewareResult instanceof HttpResponse){ |
|
63 | + if($middlewareResult instanceof HttpResponse) { |
|
64 | 64 | return $middlewareResult; |
65 | 65 | } |
66 | 66 | } |
@@ -58,13 +58,13 @@ |
||
58 | 58 | if($matcher instanceof MatchRoute) { |
59 | 59 | |
60 | 60 | foreach($this->middlewares as $middleware => $args){ |
61 | - $middlewareInstance = new $middleware(); |
|
62 | - $middlewareInstance->addMatcher($matcher); |
|
63 | - $middlewareInstance->setRequest($this->request); |
|
64 | - $middlewareResult = $middlewareInstance(...$args); |
|
65 | - if($middlewareResult instanceof HttpResponse){ |
|
61 | + $middlewareInstance = new $middleware(); |
|
62 | + $middlewareInstance->addMatcher($matcher); |
|
63 | + $middlewareInstance->setRequest($this->request); |
|
64 | + $middlewareResult = $middlewareInstance(...$args); |
|
65 | + if($middlewareResult instanceof HttpResponse){ |
|
66 | 66 | return $middlewareResult; |
67 | - } |
|
67 | + } |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | Application::$controller = $matcher->controller; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | // Add base_url to $pattern, if needed |
28 | 28 | |
29 | - $link = "%s/%s"; |
|
29 | + $link = "%s/%s"; |
|
30 | 30 | $pattern = sprintf($link, Application::getAppConfig()->base_url, $pattern); |
31 | 31 | // If it matches, return the match |
32 | 32 | $parameters = $resolver->match($pattern); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | // Check if callback is a controller method |
35 | 35 | $controller = $callback[0]; |
36 | 36 | $method = $callback[1]; |
37 | - if (! method_exists($controller, $method)) { |
|
37 | + if (!method_exists($controller, $method)) { |
|
38 | 38 | throw new Exceptions\ControllerNotFoundException("Invalid Controller and/or method in routes.php"); |
39 | 39 | } |
40 | 40 | return new MatchRoute(controller: $controller, method: $method, parameters: $parameters); |
@@ -51,25 +51,25 @@ discard block |
||
51 | 51 | */ |
52 | 52 | protected function handle(BaseMatch $matcher): HttpResponse |
53 | 53 | { |
54 | - if($matcher instanceof Match404) { |
|
54 | + if ($matcher instanceof Match404) { |
|
55 | 55 | return new NotFoundResponse(); |
56 | 56 | } |
57 | 57 | |
58 | - if($matcher instanceof MatchRoute) { |
|
58 | + if ($matcher instanceof MatchRoute) { |
|
59 | 59 | |
60 | - foreach($this->middlewares as $middleware => $args){ |
|
60 | + foreach ($this->middlewares as $middleware => $args) { |
|
61 | 61 | $middlewareInstance = new $middleware(); |
62 | 62 | $middlewareInstance->addMatcher($matcher); |
63 | 63 | $middlewareInstance->setRequest($this->request); |
64 | 64 | $middlewareResult = $middlewareInstance(...$args); |
65 | - if($middlewareResult instanceof HttpResponse){ |
|
65 | + if ($middlewareResult instanceof HttpResponse) { |
|
66 | 66 | return $middlewareResult; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | 70 | Application::$controller = $matcher->controller; |
71 | 71 | $controller = new $matcher->controller(); |
72 | - $method = $matcher->method; |
|
72 | + $method = $matcher->method; |
|
73 | 73 | return $controller->$method(...$matcher->parameters); |
74 | 74 | } |
75 | 75 | throw new \Exception("Wrong matcher!"); |
@@ -36,7 +36,7 @@ |
||
36 | 36 | |
37 | 37 | |
38 | 38 | protected function checkPermissions(string $modifier, mixed ...$params):bool{ |
39 | - if($modifier == LoginRequired::class){ |
|
39 | + if($modifier == LoginRequired::class) { |
|
40 | 40 | $authenticator = new \Lepton\Authenticator\UserAuthenticator(); |
41 | 41 | return $authenticator->isLoggedIn(); |
42 | 42 | } |
@@ -14,18 +14,17 @@ discard block |
||
14 | 14 | |
15 | 15 | protected function handle(mixed ...$middlewareParams): HttpResponse|Request |
16 | 16 | { |
17 | - if($this->match instanceof MatchRoute) { |
|
17 | + if ($this->match instanceof MatchRoute) { |
|
18 | 18 | $reflection = new \ReflectionMethod($this->match->controller, $this->match->method); |
19 | 19 | $attributes = $reflection->getAttributes(); |
20 | 20 | |
21 | 21 | foreach ($attributes as $attribute) { |
22 | - if(is_subclass_of($attribute->getName(), AbstractAccessControlAttribute::class)) { |
|
22 | + if (is_subclass_of($attribute->getName(), AbstractAccessControlAttribute::class)) { |
|
23 | 23 | return |
24 | - $this->checkPermissions($attribute->getName(), ...($attribute->getArguments()))? |
|
25 | - $this->request : |
|
26 | - new RedirectResponse( |
|
24 | + $this->checkPermissions($attribute->getName(), ...($attribute->getArguments())) ? |
|
25 | + $this->request : new RedirectResponse( |
|
27 | 26 | Application::getAuthConfig()->login_url, |
28 | - redirect_after: $this->request->url |
|
27 | + redirect_after : $this->request->url |
|
29 | 28 | ); |
30 | 29 | } |
31 | 30 | |
@@ -36,7 +35,7 @@ discard block |
||
36 | 35 | |
37 | 36 | |
38 | 37 | protected function checkPermissions(string $modifier, mixed ...$params):bool{ |
39 | - if($modifier == LoginRequired::class){ |
|
38 | + if ($modifier == LoginRequired::class) { |
|
40 | 39 | $authenticator = new \Lepton\Authenticator\UserAuthenticator(); |
41 | 40 | return $authenticator->isLoggedIn(); |
42 | 41 | } |
@@ -81,49 +81,49 @@ discard block |
||
81 | 81 | public function __construct(protected string $model) |
82 | 82 | { |
83 | 83 | $this->lookup_map = array( |
84 | - "equals" => [ |
|
84 | + "equals" => [ |
|
85 | 85 | "operator" => "=", |
86 | 86 | "rhs" => fn ($x) => $x |
87 | - ], |
|
88 | - "startswith" => [ |
|
87 | + ], |
|
88 | + "startswith" => [ |
|
89 | 89 | "operator" => "LIKE", |
90 | 90 | "rhs" => fn ($x) => sprintf('%s%%', $x) |
91 | - ], |
|
91 | + ], |
|
92 | 92 | |
93 | - "endswith" => [ |
|
93 | + "endswith" => [ |
|
94 | 94 | "operator" => "LIKE", |
95 | 95 | "rhs" => fn ($x) => sprintf('%%%s', $x) |
96 | - ], |
|
96 | + ], |
|
97 | 97 | |
98 | - "contains" => [ |
|
98 | + "contains" => [ |
|
99 | 99 | "operator" => "LIKE", |
100 | 100 | "rhs" => fn ($x) => sprintf('%%%s%%', $x) |
101 | - ], |
|
101 | + ], |
|
102 | 102 | |
103 | - "lte" => [ |
|
103 | + "lte" => [ |
|
104 | 104 | "operator" => "<=", |
105 | 105 | "rhs" => fn ($x) => $x |
106 | - ], |
|
106 | + ], |
|
107 | 107 | |
108 | - "gte" => [ |
|
108 | + "gte" => [ |
|
109 | 109 | "operator" => ">=", |
110 | 110 | "rhs" => fn ($x) => $x |
111 | - ], |
|
111 | + ], |
|
112 | 112 | |
113 | - "lt" => [ |
|
113 | + "lt" => [ |
|
114 | 114 | "operator" => "<", |
115 | 115 | "rhs" => fn ($x) => $x |
116 | - ], |
|
116 | + ], |
|
117 | 117 | |
118 | - "gt" => [ |
|
118 | + "gt" => [ |
|
119 | 119 | "operator" => ">", |
120 | 120 | "rhs" => fn ($x) => $x |
121 | - ], |
|
121 | + ], |
|
122 | 122 | |
123 | - "neq" => [ |
|
123 | + "neq" => [ |
|
124 | 124 | "operator" => "<>", |
125 | 125 | "rhs" => fn ($x) => $x |
126 | - ] |
|
126 | + ] |
|
127 | 127 | ); |
128 | 128 | |
129 | 129 | $this->filters = array(); |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | $query .= sprintf(" ORDER BY %s", $modifiers); |
494 | 494 | } |
495 | 495 | |
496 | - //if(strpos($query, "ORDER BY")) die (print_r($query)); |
|
496 | + //if(strpos($query, "ORDER BY")) die (print_r($query)); |
|
497 | 497 | return array($query, $values); |
498 | 498 | } |
499 | 499 | |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | } |
569 | 569 | }, $modifiers, array_keys($modifiers)) |
570 | 570 | );*/ |
571 | - } |
|
571 | + } |
|
572 | 572 | |
573 | 573 | |
574 | 574 | private function buildWhereClause($filters) |
@@ -674,9 +674,9 @@ discard block |
||
674 | 674 | } |
675 | 675 | |
676 | 676 | return array( |
677 | - "column" => $last->getColumnFromField($column), |
|
678 | - "condition" => $condition, |
|
679 | - "join" => $join |
|
677 | + "column" => $last->getColumnFromField($column), |
|
678 | + "condition" => $condition, |
|
679 | + "join" => $join |
|
680 | 680 | ); |
681 | 681 | } |
682 | 682 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | public function rewind(): void |
179 | 179 | { |
180 | 180 | $this->index = -1; |
181 | - if (! isset($this->result)) { |
|
181 | + if (!isset($this->result)) { |
|
182 | 182 | $this->cache = array(); |
183 | 183 | $this->do(); |
184 | 184 | } |
@@ -219,8 +219,8 @@ discard block |
||
219 | 219 | $db_columns = $this->current->db_columns(); |
220 | 220 | // Convert column names to field names |
221 | 221 | $fields = array(); |
222 | - foreach($items as $column => $value){ |
|
223 | - $fieldName = array_search($column ,$db_columns); |
|
222 | + foreach ($items as $column => $value) { |
|
223 | + $fieldName = array_search($column, $db_columns); |
|
224 | 224 | $fields[$fieldName] = $value; |
225 | 225 | } |
226 | 226 | $this->current->load(...$fields); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $this->current->clearEditedFields(); |
229 | 229 | } else { |
230 | 230 | $this->current = null; |
231 | - $this->index = -1; |
|
231 | + $this->index = -1; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | |
240 | 240 | public function first() |
241 | 241 | { |
242 | - if(!isset($this->cache)) { |
|
242 | + if (!isset($this->cache)) { |
|
243 | 243 | $this->rewind(); |
244 | 244 | } |
245 | 245 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | |
400 | 400 | public function count(): int |
401 | 401 | { |
402 | - if (! isset($this->result)) { |
|
402 | + if (!isset($this->result)) { |
|
403 | 403 | $this->do(); |
404 | 404 | } |
405 | 405 | return $this->result->num_rows; |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | |
435 | 435 | |
436 | 436 | // Get the result |
437 | - $this->result = $result->fetch_result() ; |
|
437 | + $this->result = $result->fetch_result(); |
|
438 | 438 | return $this; |
439 | 439 | } |
440 | 440 | |
@@ -469,12 +469,12 @@ discard block |
||
469 | 469 | $modifiers = ""; |
470 | 470 | |
471 | 471 | // it there are any ORDER BY, build the clause |
472 | - if (count($this->modifiers)> 0) { |
|
472 | + if (count($this->modifiers) > 0) { |
|
473 | 473 | list($modifiers, $join) = $this->buildModifiers(); |
474 | 474 | } |
475 | 475 | |
476 | 476 | // if there are any filters build WHERE clause |
477 | - if (count($this->filters)> 0) { |
|
477 | + if (count($this->filters) > 0) { |
|
478 | 478 | list($whereClause, $values, $join_t) = $this->buildWhereClause($this->filters); |
479 | 479 | } |
480 | 480 | |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | $query .= " ".$this->buildJoin($join); |
485 | 485 | $query .= " ".$this->buildJoin($join_t); |
486 | 486 | |
487 | - if(count($this->filters)>0){ |
|
487 | + if (count($this->filters) > 0) { |
|
488 | 488 | $query .= sprintf(" WHERE %s ", $whereClause); |
489 | 489 | } |
490 | 490 | |
491 | 491 | // it there are any ORDER BY, build the clause |
492 | - if (count($this->modifiers)> 0) { |
|
492 | + if (count($this->modifiers) > 0) { |
|
493 | 493 | $query .= sprintf(" ORDER BY %s", $modifiers); |
494 | 494 | } |
495 | 495 | |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | |
520 | 520 | $clause = array(); |
521 | 521 | for ($i = 1; $i < count($join); $i++) { |
522 | - $clause[] = sprintf( |
|
522 | + $clause[] = sprintf( |
|
523 | 523 | " %s ON %s.%s = %s.%s", |
524 | 524 | $join[$i]["table"], |
525 | - $join[$i-1]["table"], |
|
525 | + $join[$i - 1]["table"], |
|
526 | 526 | $join[$i]["column"], |
527 | 527 | $join[$i]["table"], |
528 | 528 | $join[$i]["column"] |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | $order_by = $this->modifiers["ORDER BY"]; |
540 | 540 | $conditions = array(); |
541 | 541 | $join = array(); |
542 | - foreach($order_by as $raw) { |
|
542 | + foreach ($order_by as $raw) { |
|
543 | 543 | $parsed = $this->lookup($raw); |
544 | 544 | |
545 | 545 | $column = $parsed["column"]; |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | $values = array(); |
603 | 603 | $join = array(); |
604 | 604 | |
605 | - foreach($filters as $key => $value) { |
|
605 | + foreach ($filters as $key => $value) { |
|
606 | 606 | $lookup = $this->lookup($key); |
607 | 607 | |
608 | 608 | $column = $lookup["column"]; |
@@ -651,8 +651,8 @@ discard block |
||
651 | 651 | |
652 | 652 | $join = array(); |
653 | 653 | foreach ($match as $k) { |
654 | - if($last->isForeignKey($k)) { |
|
655 | - $new= new ($last->getRelationshipParentModel($k))(); |
|
654 | + if ($last->isForeignKey($k)) { |
|
655 | + $new = new ($last->getRelationshipParentModel($k))(); |
|
656 | 656 | |
657 | 657 | $join[] = array( |
658 | 658 | "column"=> $last->getColumnFromField($k), |
@@ -414,11 +414,13 @@ discard block |
||
414 | 414 | * @return QuerySet |
415 | 415 | */ |
416 | 416 | |
417 | - public function do(): QuerySet |
|
417 | + public function do { |
|
418 | + (): QuerySet |
|
418 | 419 | { |
419 | 420 | |
420 | 421 | // Build the query |
421 | 422 | list($query, $values) = $this->buildQuery(); |
423 | + } |
|
422 | 424 | |
423 | 425 | // Connect to DB |
424 | 426 | $db = Application::getDb(); |
@@ -484,7 +486,7 @@ discard block |
||
484 | 486 | $query .= " ".$this->buildJoin($join); |
485 | 487 | $query .= " ".$this->buildJoin($join_t); |
486 | 488 | |
487 | - if(count($this->filters)>0){ |
|
489 | + if(count($this->filters)>0) { |
|
488 | 490 | $query .= sprintf(" WHERE %s ", $whereClause); |
489 | 491 | } |
490 | 492 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | echo "Running...".PHP_EOL; |
20 | 20 | |
21 | - if(is_dir($this->sass_directory)) { |
|
21 | + if (is_dir($this->sass_directory)) { |
|
22 | 22 | // Clean output folder |
23 | 23 | array_map('unlink', array_filter((array) glob($this->css_directory."*"))); |
24 | 24 | |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | $this->updateMainFiles(); |
29 | 29 | |
30 | 30 | // Compile the files |
31 | - foreach($this->fileHashes as $file => $hash) { |
|
31 | + foreach ($this->fileHashes as $file => $hash) { |
|
32 | 32 | |
33 | 33 | $file = realpath($file); |
34 | 34 | $fileDependancies = $this->compileFile($file); |
35 | 35 | $this->fileHashes[$file] = filemtime($file); |
36 | 36 | $this->dependancyTree[$file] = $fileDependancies; |
37 | - foreach($fileDependancies as $dep) { |
|
37 | + foreach ($fileDependancies as $dep) { |
|
38 | 38 | $this->fileHashes[realpath($dep)] = filemtime($dep); |
39 | 39 | } |
40 | 40 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | echo "Dependancies tree built.".PHP_EOL.PHP_EOL; |
44 | 44 | |
45 | 45 | // Compute md5 hash for files |
46 | - foreach($this->dependancyTree as $file => $where) { |
|
46 | + foreach ($this->dependancyTree as $file => $where) { |
|
47 | 47 | $fileHashes[$file] = filemtime($file); |
48 | 48 | } |
49 | 49 | |
@@ -68,24 +68,24 @@ discard block |
||
68 | 68 | //Start the PHP built-in web server |
69 | 69 | $command = sprintf('php -S localhost:5555 -t %s %s/webserver.php', $this->application, $this->application); |
70 | 70 | $this->webServerProcess = proc_open($command, [STDIN, STDOUT, STDERR], $pipes); |
71 | - while(true) { |
|
72 | - if($this->compile_sass) { |
|
71 | + while (true) { |
|
72 | + if ($this->compile_sass) { |
|
73 | 73 | $this->cleanDeletedFiles(); |
74 | 74 | $this->updateMainFiles(); |
75 | - foreach($this->fileHashes as $file => $hash) { |
|
75 | + foreach ($this->fileHashes as $file => $hash) { |
|
76 | 76 | $file = realpath($file); |
77 | - if(file_exists($file)) { |
|
77 | + if (file_exists($file)) { |
|
78 | 78 | $newHash = filemtime($file); |
79 | - if($newHash != $hash) { |
|
79 | + if ($newHash != $hash) { |
|
80 | 80 | echo "\e[93mFile $file modified!\e[39m".PHP_EOL; |
81 | 81 | $this->fileHashes[$file] = $newHash; |
82 | 82 | |
83 | 83 | // if it's a main file |
84 | - if(key_exists($file, $this->dependancyTree)) { |
|
84 | + if (key_exists($file, $this->dependancyTree)) { |
|
85 | 85 | $this->dependancyTree[$file] = $this->compileFile($file); |
86 | 86 | } else { // if it's an included file |
87 | - foreach($this->dependancyTree as $main => $dependancies) { |
|
88 | - if(in_array($file, $dependancies)) { |
|
87 | + foreach ($this->dependancyTree as $main => $dependancies) { |
|
88 | + if (in_array($file, $dependancies)) { |
|
89 | 89 | $this->dependancyTree[$main] = $this->compileFile($main); |
90 | 90 | } |
91 | 91 | } |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | public function cleanDeletedFiles() |
114 | 114 | { |
115 | 115 | |
116 | - foreach($this->fileHashes as $file => $hash) { |
|
117 | - if(!file_exists($file)) { |
|
116 | + foreach ($this->fileHashes as $file => $hash) { |
|
117 | + if (!file_exists($file)) { |
|
118 | 118 | unset($fileHashes[$file]); |
119 | - foreach($this->dependancyTree as $main => $dependancies) { |
|
120 | - if($main == $file) { |
|
119 | + foreach ($this->dependancyTree as $main => $dependancies) { |
|
120 | + if ($main == $file) { |
|
121 | 121 | unset($this->dependancyTree[$main]); |
122 | 122 | } |
123 | - if(in_array($file, $dependancies)) { |
|
123 | + if (in_array($file, $dependancies)) { |
|
124 | 124 | $key = array_search($file, $dependancies); |
125 | 125 | unset($this->dependancyTree[$main][$key]); |
126 | 126 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | if (is_file($inputFile)) { |
141 | 141 | // Set the path to the output CSS file |
142 | 142 | $outputFile = preg_replace('/(.*)\.(sass|scss)$/', '$1.css', basename($inputFile)); |
143 | - $outputFile = $this->css_directory.$outputFile; |
|
143 | + $outputFile = $this->css_directory.$outputFile; |
|
144 | 144 | // Compile the SCSS code into CSS |
145 | 145 | try { |
146 | 146 | $result = $compiler->compileString(file_get_contents($inputFile)); |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | |
176 | 176 | public function updateMainFiles() |
177 | 177 | { |
178 | - $files = glob($this->sass_directory . '/*'); // Get all files in the directory |
|
178 | + $files = glob($this->sass_directory.'/*'); // Get all files in the directory |
|
179 | 179 | |
180 | 180 | |
181 | 181 | foreach ($files as $file) { |
182 | 182 | $file = realpath($file); |
183 | - $pattern = '/^\/.+\/[^_]*[.](scss|sass)/'; // Specify the regex pattern for file names |
|
184 | - if(preg_match($pattern, $file)) { |
|
185 | - if(! array_key_exists($file, $this->fileHashes)) { |
|
183 | + $pattern = '/^\/.+\/[^_]*[.](scss|sass)/'; // Specify the regex pattern for file names |
|
184 | + if (preg_match($pattern, $file)) { |
|
185 | + if (!array_key_exists($file, $this->fileHashes)) { |
|
186 | 186 | $this->fileHashes[$file] = 0; |
187 | 187 | } |
188 | 188 | } |
@@ -83,7 +83,8 @@ |
||
83 | 83 | // if it's a main file |
84 | 84 | if(key_exists($file, $this->dependancyTree)) { |
85 | 85 | $this->dependancyTree[$file] = $this->compileFile($file); |
86 | - } else { // if it's an included file |
|
86 | + } else { |
|
87 | +// if it's an included file |
|
87 | 88 | foreach($this->dependancyTree as $main => $dependancies) { |
88 | 89 | if(in_array($file, $dependancies)) { |
89 | 90 | $this->dependancyTree[$main] = $this->compileFile($main); |