Passed
Push — RefactoringPosts ( 744e11...92981d )
by Stone
01:58
created
App/Modules/Pagination.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
             throw new \Exception("Pagination Error", "404");
27 27
         }
28 28
         $pageNo = $this->removeFromBeginning($page, "page-");
29
-        if(!filter_var($pageNo, FILTER_VALIDATE_INT)){
29
+        if (!filter_var($pageNo, FILTER_VALIDATE_INT)) {
30 30
             throw new \Exception("Invalid page number");
31 31
         }
32 32
         $offset = ($pageNo - 1) * $rowsPerPage;
Please login to merge, or discard this patch.
App/Controllers/Admin/Home.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 {
9 9
     public function index()
10 10
     {
11
-        if(!$this->auth->isUser()){
11
+        if (!$this->auth->isUser()) {
12 12
             $this->alertBox->setAlert("You must be connected to access the admin interface", 'warning');
13 13
             $this->container->getResponse()->redirect();
14 14
         }
Please login to merge, or discard this patch.
App/Controllers/Ajax/postModification.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 use Core\AjaxController;
7 7
 use Core\Container;
8 8
 
9
-class postModification extends AjaxController{
9
+class postModification extends AjaxController {
10 10
 
11 11
 
12 12
     private $postModule;
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
         if (!$this->container->getRequest()->isPost()) {
24 24
             throw new \Core\JsonException('Call is not post');
25 25
         }
26
-        $state = (bool)($this->request->getData("state") === 'true');
27
-        $postId = (int)$this->request->getData("postId");
26
+        $state = (bool) ($this->request->getData("state") === 'true');
27
+        $postId = (int) $this->request->getData("postId");
28 28
 
29 29
         $result["success"] = $this->postModule->setPublished(!$state, $postId);
30 30
         $result["state"] = !$state;
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
             throw new \Core\JsonException('Call is not post');
40 40
         }
41 41
         $state = ($this->request->getData("state") === 'true');
42
-        $postId = (int)$this->request->getData("postId");
42
+        $postId = (int) $this->request->getData("postId");
43 43
 
44 44
         $result["success"] = $this->postModule->setOnFrontPage(!$state, $postId);
45 45
         $result["state"] = !$state;
Please login to merge, or discard this patch.
Core/Constant.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,5 +23,5 @@
 block discarded – undo
23 23
     const POSTS_PER_PAGE = 4;
24 24
     const LIST_PER_PAGE = 10;
25 25
 
26
-    const EXCERPT_WORD_COUNT =50;
26
+    const EXCERPT_WORD_COUNT = 50;
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
App/Controllers/Admin/Tag.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use Core\Constant;
8 8
 use Core\Container;
9 9
 
10
-class Tag extends AdminController{
10
+class Tag extends AdminController {
11 11
 
12 12
     protected $siteConfig;
13 13
     protected $pagination;
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         $totalCategories = $this->tagModel->countTags();
33 33
         $pagination = $this->pagination->getPagination($page, $totalCategories, $linesPerPage);
34 34
 
35
-        if($linesPerPage !== Constant::LIST_PER_PAGE){
35
+        if ($linesPerPage !== Constant::LIST_PER_PAGE) {
36 36
             $this->data['paginationPostsPerPage'] = $linesPerPage;
37 37
         }
38 38
 
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 
61 61
 
62 62
         //Sanity check on ID
63
-        if($tagId == null )
63
+        if ($tagId == null)
64 64
         {
65 65
             throw new \ErrorException("invalid tag ID");
66 66
         }
67 67
 
68 68
         //Error checking
69 69
         $error = false;
70
-        if($tagName == "")
70
+        if ($tagName == "")
71 71
         {
72 72
             $error = true;
73 73
             $this->alertBox->setAlert("empty name not allowed", "error");
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 
82 82
         //checking result and redirecting
83 83
         if ($tagUpdate) {
84
-            $this->alertBox->setAlert("Tag " . $tagName . " updated");
84
+            $this->alertBox->setAlert("Tag ".$tagName." updated");
85 85
             $this->response->redirect("/admin/tag/list/");
86 86
         }
87
-        $this->alertBox->setAlert("Error updating " . $tagName, "error");
87
+        $this->alertBox->setAlert("Error updating ".$tagName, "error");
88 88
         $this->response->redirect("/admin/tag/list/");
89 89
     }
90 90
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 
101 101
         $removedTag = $this->tagModel->delete($tagId);
102 102
 
103
-        if($removedTag)
103
+        if ($removedTag)
104 104
         {
105 105
             $this->alertBox->setAlert("Tag ".$tagName." deleted");
106 106
         }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
         //Error checking
127 127
         $error = false;
128
-        if($tagName == "")
128
+        if ($tagName == "")
129 129
         {
130 130
             $error = true;
131 131
             $this->alertBox->setAlert("empty name not allowed", "error");
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 
140 140
         //checking result and redirecting
141 141
         if ($tagNew) {
142
-            $this->alertBox->setAlert("Tag " . $tagName . " created");
142
+            $this->alertBox->setAlert("Tag ".$tagName." created");
143 143
             $this->response->redirect("/admin/tag/list/");
144 144
         }
145
-        $this->alertBox->setAlert("Error creating " . $tagName, "error");
145
+        $this->alertBox->setAlert("Error creating ".$tagName, "error");
146 146
         $this->response->redirect("/admin/tag/list/");
147 147
     }
148 148
 }
149 149
\ No newline at end of file
Please login to merge, or discard this patch.
App/Controllers/Ajax/Tag.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 use App\Models\TagModel;
6 6
 use Core\AjaxController;
7 7
 
8
-class Tag extends AjaxController{
8
+class Tag extends AjaxController {
9 9
 
10 10
 
11 11
     /**
Please login to merge, or discard this patch.
App/Controllers/Post.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use Core\Controller;
9 9
 use Core\Container;
10 10
 
11
-class Post extends Controller{
11
+class Post extends Controller {
12 12
 
13 13
     protected $siteConfig;
14 14
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      * @throws \Twig_Error_Runtime
27 27
      * @throws \Twig_Error_Syntax
28 28
      */
29
-    public function viewPost(string $slug){
29
+    public function viewPost(string $slug) {
30 30
 
31 31
         $tagModel = new TagModel($this->container);
32 32
         $postModel = new PostModel($this->container);
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
         $posts = $postModel->getSinglePost($postId);
39 39
 
40 40
         //only admins can view unpublished posts
41
-        if(!$posts->published)
41
+        if (!$posts->published)
42 42
         {
43
-            if(!$this->auth->isAdmin())
43
+            if (!$this->auth->isAdmin())
44 44
             {
45 45
                 throw new \Exception("File does not exist", "404");
46 46
             }
Please login to merge, or discard this patch.
App/Modules/SiteConfig.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
         $categories = $categoryModel->getCategories();
35 35
         foreach ($categories as $category) {
36 36
             $data += [
37
-                $category->category_name => '/category/posts/' . $category->categories_slug
37
+                $category->category_name => '/category/posts/'.$category->categories_slug
38 38
             ];
39 39
         }
40 40
         return $data;
Please login to merge, or discard this patch.
Core/Model.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
             $table = $reflect->getShortName(); //this is to only get the model name, otherwise we get the full namespace
140 140
             //since our models all end with Model, we should remove it.
141 141
             $table = $this->removeFromEnd($table, 'Model');
142
-            $table = $table . 's'; //adding the s since the table should be plural. Might be some special case where the plural isn't just with an s
142
+            $table = $table.'s'; //adding the s since the table should be plural. Might be some special case where the plural isn't just with an s
143 143
             $table = strtolower($table); //the database names are in lowercase
144 144
         }
145 145
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         }
163 163
 
164 164
         //if we are here, then table doesn't exist, check for view
165
-        $view = 'v_' . $table;
165
+        $view = 'v_'.$table;
166 166
         $stmt->bindValue(':table', $view, PDO::PARAM_STR);
167 167
         $stmt->execute();
168 168
         $exists = $stmt->rowCount() > 0; //will return 1 if table exists or 0 if non existant
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
     protected function getTablePrefix($table)
187 187
     {
188 188
         if (Config::TABLE_PREFIX != '') {
189
-            $table = Config::TABLE_PREFIX . '_' . $table;
189
+            $table = Config::TABLE_PREFIX.'_'.$table;
190 190
         }
191 191
         return $table;
192 192
     }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
     protected function getRowById($rowId, $table = null)
256 256
     {
257 257
         $tableName = $this->getTable($table);
258
-        $idName = 'id' . $tableName;
258
+        $idName = 'id'.$tableName;
259 259
         $sql = "SELECT * FROM $tableName WHERE $idName = :rowId";
260 260
         $this->query($sql);
261 261
         $this->bind(':rowId', $rowId);
Please login to merge, or discard this patch.