Passed
Branch develop (96efe9)
by Jens
02:38
created
src/storage/storage/SitemapStorage.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -12,111 +12,111 @@
 block discarded – undo
12 12
 
13 13
 class SitemapStorage extends AbstractStorage
14 14
 {
15
-	/**
16
-	 * @return array
17
-	 */
18
-	public function getSitemap()
19
-	{
20
-		return $this->repository->sitemap;
21
-	}
15
+    /**
16
+     * @return array
17
+     */
18
+    public function getSitemap()
19
+    {
20
+        return $this->repository->sitemap;
21
+    }
22 22
 
23
-	/**
24
-	 * Add a sitemap item
25
-	 *
26
-	 * @param $postValues
27
-	 *
28
-	 * @throws \Exception
29
-	 */
30
-	public function addSitemapItem($postValues)
31
-	{
32
-		$sitemapObject = SitemapItemFactory::createSitemapItemFromPostValues($postValues);
33
-		$sitemap = $this->repository->sitemap;
34
-		$sitemap[] = $sitemapObject;
35
-		$this->repository->sitemap = $sitemap;
36
-		$this->save();
37
-	}
23
+    /**
24
+     * Add a sitemap item
25
+     *
26
+     * @param $postValues
27
+     *
28
+     * @throws \Exception
29
+     */
30
+    public function addSitemapItem($postValues)
31
+    {
32
+        $sitemapObject = SitemapItemFactory::createSitemapItemFromPostValues($postValues);
33
+        $sitemap = $this->repository->sitemap;
34
+        $sitemap[] = $sitemapObject;
35
+        $this->repository->sitemap = $sitemap;
36
+        $this->save();
37
+    }
38 38
 
39
-	/**
40
-	 * Save changes to a sitemap item
41
-	 *
42
-	 * @param $slug
43
-	 * @param $postValues
44
-	 *
45
-	 * @throws \Exception
46
-	 */
47
-	public function saveSitemapItem($slug, $postValues)
48
-	{
49
-		$sitemapObject = SitemapItemFactory::createSitemapItemFromPostValues($postValues);
39
+    /**
40
+     * Save changes to a sitemap item
41
+     *
42
+     * @param $slug
43
+     * @param $postValues
44
+     *
45
+     * @throws \Exception
46
+     */
47
+    public function saveSitemapItem($slug, $postValues)
48
+    {
49
+        $sitemapObject = SitemapItemFactory::createSitemapItemFromPostValues($postValues);
50 50
 
51
-		$sitemap = $this->repository->sitemap;
52
-		foreach ($sitemap as $key => $sitemapItem) {
53
-			if ($sitemapItem->slug == $slug) {
54
-				$sitemap[$key] = $sitemapObject;
55
-			}
56
-		}
57
-		$this->repository->sitemap = $sitemap;
58
-		$this->save();
59
-	}
51
+        $sitemap = $this->repository->sitemap;
52
+        foreach ($sitemap as $key => $sitemapItem) {
53
+            if ($sitemapItem->slug == $slug) {
54
+                $sitemap[$key] = $sitemapObject;
55
+            }
56
+        }
57
+        $this->repository->sitemap = $sitemap;
58
+        $this->save();
59
+    }
60 60
 
61
-	/**
62
-	 * Delete a sitemap item by its slug
63
-	 *
64
-	 * @param $slug
65
-	 *
66
-	 * @throws \Exception
67
-	 */
68
-	public function deleteSitemapItemBySlug($slug)
69
-	{
70
-		$sitemap = $this->repository->sitemap;
71
-		foreach ($sitemap as $key => $sitemapItem) {
72
-			if ($sitemapItem->slug == $slug) {
73
-				unset($sitemap[$key]);
74
-			}
75
-		}
76
-		$sitemap = array_values($sitemap);
77
-		$this->repository->sitemap = $sitemap;
78
-		$this->save();
79
-	}
61
+    /**
62
+     * Delete a sitemap item by its slug
63
+     *
64
+     * @param $slug
65
+     *
66
+     * @throws \Exception
67
+     */
68
+    public function deleteSitemapItemBySlug($slug)
69
+    {
70
+        $sitemap = $this->repository->sitemap;
71
+        foreach ($sitemap as $key => $sitemapItem) {
72
+            if ($sitemapItem->slug == $slug) {
73
+                unset($sitemap[$key]);
74
+            }
75
+        }
76
+        $sitemap = array_values($sitemap);
77
+        $this->repository->sitemap = $sitemap;
78
+        $this->save();
79
+    }
80 80
 
81
-	/**
82
-	 * Save changes to a sitemap item
83
-	 *
84
-	 * @param $postValues
85
-	 *
86
-	 * @throws \Exception
87
-	 */
88
-	public function saveSitemap($postValues)
89
-	{
90
-		if (isset($postValues['sitemapitem']) && is_array($postValues['sitemapitem'])) {
91
-			$sitemap = array();
92
-			foreach ($postValues['sitemapitem'] as $sitemapItem) {
93
-				$sitemapItemObject = json_decode($sitemapItem);
94
-				if (isset($sitemapItemObject->object)) {
95
-					unset($sitemapItemObject->object);
96
-				}
97
-				$sitemap[] = $sitemapItemObject;
98
-			}
99
-			$this->repository->sitemap = $sitemap;
100
-			$this->save();
101
-		}
102
-	}
81
+    /**
82
+     * Save changes to a sitemap item
83
+     *
84
+     * @param $postValues
85
+     *
86
+     * @throws \Exception
87
+     */
88
+    public function saveSitemap($postValues)
89
+    {
90
+        if (isset($postValues['sitemapitem']) && is_array($postValues['sitemapitem'])) {
91
+            $sitemap = array();
92
+            foreach ($postValues['sitemapitem'] as $sitemapItem) {
93
+                $sitemapItemObject = json_decode($sitemapItem);
94
+                if (isset($sitemapItemObject->object)) {
95
+                    unset($sitemapItemObject->object);
96
+                }
97
+                $sitemap[] = $sitemapItemObject;
98
+            }
99
+            $this->repository->sitemap = $sitemap;
100
+            $this->save();
101
+        }
102
+    }
103 103
 
104
-	/**
105
-	 * Get a sitemap item by its slug
106
-	 *
107
-	 * @param $slug
108
-	 *
109
-	 * @return mixed
110
-	 */
111
-	public function getSitemapItemBySlug($slug)
112
-	{
113
-		$sitemap = $this->repository->sitemap;
114
-		foreach ($sitemap as $sitemapItem) {
115
-			if ($sitemapItem->slug == $slug) {
116
-				return $sitemapItem;
117
-			}
118
-		}
104
+    /**
105
+     * Get a sitemap item by its slug
106
+     *
107
+     * @param $slug
108
+     *
109
+     * @return mixed
110
+     */
111
+    public function getSitemapItemBySlug($slug)
112
+    {
113
+        $sitemap = $this->repository->sitemap;
114
+        foreach ($sitemap as $sitemapItem) {
115
+            if ($sitemapItem->slug == $slug) {
116
+                return $sitemapItem;
117
+            }
118
+        }
119 119
 
120
-		return null;
121
-	}
120
+        return null;
121
+    }
122 122
 }
123 123
\ No newline at end of file
Please login to merge, or discard this patch.
src/storage/storage/ImageSetStorage.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -11,119 +11,119 @@
 block discarded – undo
11 11
 class ImageSetStorage extends AbstractStorage
12 12
 {
13 13
 
14
-	/**
15
-	 * @return mixed
16
-	 */
17
-	public function getImageSet()
18
-	{
19
-		return $this->repository->imageSet;
20
-	}
21
-
22
-	/**
23
-	 * Get Image by slug
24
-	 *
25
-	 * @param $slug
26
-	 *
27
-	 * @return \stdClass
28
-	 */
29
-	public function getImageSetBySlug($slug)
30
-	{
31
-		$imageSet = $this->getImageSet();
32
-		foreach ($imageSet as $set) {
33
-			if ($set->slug == $slug) {
34
-				return $set;
35
-			}
36
-		}
37
-
38
-		return null;
39
-	}
40
-
41
-	/**
42
-	 * Add image set
43
-	 *
44
-	 * @param $postValues
45
-	 *
46
-	 * @throws \Exception
47
-	 */
48
-	public function addImageSet($postValues)
49
-	{
50
-		$imageSetObject = ImageSetFactory::createImageSetFromPostValues($postValues);
51
-
52
-		$imageSet = $this->repository->imageSet;
53
-		$imageSet[] = $imageSetObject;
54
-		$this->repository->imageSet = $imageSet;
55
-
56
-		$this->save();
57
-	}
58
-
59
-	/**
60
-	 * Save Image Set by it's slug
61
-	 *
62
-	 * @param $slug
63
-	 * @param $postValues
64
-	 *
65
-	 * @throws \Exception
66
-	 */
67
-	public function saveImageSet($slug, $postValues)
68
-	{
69
-		$imageSetObject = ImageSetFactory::createImageSetFromPostValues($postValues);
70
-
71
-		$imageSet = $this->repository->imageSet;
72
-		foreach ($imageSet as $key => $set) {
73
-			if ($set->slug == $slug) {
74
-				$imageSet[$key] = $imageSetObject;
75
-			}
76
-		}
77
-		$this->repository->imageSet = $imageSet;
78
-		$this->save();
79
-	}
80
-
81
-	/**
82
-	 * Delete Image Set by its slug
83
-	 *
84
-	 * @param $slug
85
-	 *
86
-	 * @throws \Exception
87
-	 */
88
-	public function deleteImageSetBySlug($slug)
89
-	{
90
-		$imageSet = $this->getImageSet();
91
-
92
-		foreach ($imageSet as $key => $set) {
93
-			if ($set->slug == $slug) {
94
-				unset($imageSet[$key]);
95
-			}
96
-		}
97
-		$imageSet = array_values($imageSet);
98
-		$this->repository->imageSet = $imageSet;
99
-		$this->save();
100
-	}
101
-
102
-	/**
103
-	 * Get the image set with the smallest size
104
-	 *
105
-	 * @return \stdClass
106
-	 */
107
-	public function getSmallestImageSet()
108
-	{
109
-		$imageSet = $this->getImageSet();
110
-
111
-		$returnSize = PHP_INT_MAX;
112
-		$returnSet = null;
113
-
114
-		foreach ($imageSet as $set) {
115
-			$size = $set->width * $set->height;
116
-			if ($size < $returnSize) {
117
-				$returnSize = $size;
118
-				$returnSet = $set;
119
-			}
120
-		}
121
-
122
-		if ($returnSet === null) {
123
-			$returnSet = new \stdClass();
124
-			$returnSet->slug = 'original';
125
-		}
126
-
127
-		return $returnSet;
128
-	}
14
+    /**
15
+     * @return mixed
16
+     */
17
+    public function getImageSet()
18
+    {
19
+        return $this->repository->imageSet;
20
+    }
21
+
22
+    /**
23
+     * Get Image by slug
24
+     *
25
+     * @param $slug
26
+     *
27
+     * @return \stdClass
28
+     */
29
+    public function getImageSetBySlug($slug)
30
+    {
31
+        $imageSet = $this->getImageSet();
32
+        foreach ($imageSet as $set) {
33
+            if ($set->slug == $slug) {
34
+                return $set;
35
+            }
36
+        }
37
+
38
+        return null;
39
+    }
40
+
41
+    /**
42
+     * Add image set
43
+     *
44
+     * @param $postValues
45
+     *
46
+     * @throws \Exception
47
+     */
48
+    public function addImageSet($postValues)
49
+    {
50
+        $imageSetObject = ImageSetFactory::createImageSetFromPostValues($postValues);
51
+
52
+        $imageSet = $this->repository->imageSet;
53
+        $imageSet[] = $imageSetObject;
54
+        $this->repository->imageSet = $imageSet;
55
+
56
+        $this->save();
57
+    }
58
+
59
+    /**
60
+     * Save Image Set by it's slug
61
+     *
62
+     * @param $slug
63
+     * @param $postValues
64
+     *
65
+     * @throws \Exception
66
+     */
67
+    public function saveImageSet($slug, $postValues)
68
+    {
69
+        $imageSetObject = ImageSetFactory::createImageSetFromPostValues($postValues);
70
+
71
+        $imageSet = $this->repository->imageSet;
72
+        foreach ($imageSet as $key => $set) {
73
+            if ($set->slug == $slug) {
74
+                $imageSet[$key] = $imageSetObject;
75
+            }
76
+        }
77
+        $this->repository->imageSet = $imageSet;
78
+        $this->save();
79
+    }
80
+
81
+    /**
82
+     * Delete Image Set by its slug
83
+     *
84
+     * @param $slug
85
+     *
86
+     * @throws \Exception
87
+     */
88
+    public function deleteImageSetBySlug($slug)
89
+    {
90
+        $imageSet = $this->getImageSet();
91
+
92
+        foreach ($imageSet as $key => $set) {
93
+            if ($set->slug == $slug) {
94
+                unset($imageSet[$key]);
95
+            }
96
+        }
97
+        $imageSet = array_values($imageSet);
98
+        $this->repository->imageSet = $imageSet;
99
+        $this->save();
100
+    }
101
+
102
+    /**
103
+     * Get the image set with the smallest size
104
+     *
105
+     * @return \stdClass
106
+     */
107
+    public function getSmallestImageSet()
108
+    {
109
+        $imageSet = $this->getImageSet();
110
+
111
+        $returnSize = PHP_INT_MAX;
112
+        $returnSet = null;
113
+
114
+        foreach ($imageSet as $set) {
115
+            $size = $set->width * $set->height;
116
+            if ($size < $returnSize) {
117
+                $returnSize = $size;
118
+                $returnSet = $set;
119
+            }
120
+        }
121
+
122
+        if ($returnSet === null) {
123
+            $returnSet = new \stdClass();
124
+            $returnSet->slug = 'original';
125
+        }
126
+
127
+        return $returnSet;
128
+    }
129 129
 }
130 130
\ No newline at end of file
Please login to merge, or discard this patch.
src/storage/storage/UsersStorage.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -10,129 +10,129 @@
 block discarded – undo
10 10
 
11 11
 class UsersStorage extends AbstractStorage
12 12
 {
13
-	/**
14
-	 * Get all users
15
-	 *
16
-	 * @return mixed
17
-	 */
18
-	public function getUsers()
19
-	{
20
-		return $this->repository->users;
21
-	}
13
+    /**
14
+     * Get all users
15
+     *
16
+     * @return mixed
17
+     */
18
+    public function getUsers()
19
+    {
20
+        return $this->repository->users;
21
+    }
22 22
 
23
-	/**
24
-	 * Get user by slug
25
-	 *
26
-	 * @param $slug
27
-	 *
28
-	 * @return array
29
-	 */
30
-	public function getUserBySlug($slug)
31
-	{
32
-		$return = array();
23
+    /**
24
+     * Get user by slug
25
+     *
26
+     * @param $slug
27
+     *
28
+     * @return array
29
+     */
30
+    public function getUserBySlug($slug)
31
+    {
32
+        $return = array();
33 33
 
34
-		$users = $this->repository->users;
35
-		foreach ($users as $user) {
36
-			if ($user->slug == $slug) {
37
-				$return = $user;
38
-				break;
39
-			}
40
-		}
34
+        $users = $this->repository->users;
35
+        foreach ($users as $user) {
36
+            if ($user->slug == $slug) {
37
+                $return = $user;
38
+                break;
39
+            }
40
+        }
41 41
 
42
-		return $return;
43
-	}
42
+        return $return;
43
+    }
44 44
 
45
-	/**
46
-	 * Save user
47
-	 *
48
-	 * @param $slug
49
-	 * @param $postValues
50
-	 *
51
-	 * @throws \Exception
52
-	 */
53
-	public function saveUser($slug, $postValues)
54
-	{
55
-		$userObj = UserFactory::createUserFromPostValues($postValues);
56
-		if ($userObj->slug != $slug) {
57
-			// If the username changed, check for duplicates
58
-			$doesItExist = $this->getUserBySlug($userObj->slug);
59
-			if (!empty($doesItExist)) {
60
-				throw new \Exception('Trying to rename user to existing username');
61
-			}
62
-		}
63
-		$users = $this->getUsers();
64
-		foreach ($users as $key => $user) {
65
-			if ($user->slug == $slug) {
66
-				$users[$key] = $userObj;
67
-			}
68
-		}
69
-		$this->repository->users = $users;
70
-		$this->save();
71
-	}
45
+    /**
46
+     * Save user
47
+     *
48
+     * @param $slug
49
+     * @param $postValues
50
+     *
51
+     * @throws \Exception
52
+     */
53
+    public function saveUser($slug, $postValues)
54
+    {
55
+        $userObj = UserFactory::createUserFromPostValues($postValues);
56
+        if ($userObj->slug != $slug) {
57
+            // If the username changed, check for duplicates
58
+            $doesItExist = $this->getUserBySlug($userObj->slug);
59
+            if (!empty($doesItExist)) {
60
+                throw new \Exception('Trying to rename user to existing username');
61
+            }
62
+        }
63
+        $users = $this->getUsers();
64
+        foreach ($users as $key => $user) {
65
+            if ($user->slug == $slug) {
66
+                $users[$key] = $userObj;
67
+            }
68
+        }
69
+        $this->repository->users = $users;
70
+        $this->save();
71
+    }
72 72
 
73
-	/**
74
-	 * Add user
75
-	 *
76
-	 * @param $postValues
77
-	 *
78
-	 * @throws \Exception
79
-	 */
80
-	public function addUser($postValues)
81
-	{
82
-		$userObj = UserFactory::createUserFromPostValues($postValues);
73
+    /**
74
+     * Add user
75
+     *
76
+     * @param $postValues
77
+     *
78
+     * @throws \Exception
79
+     */
80
+    public function addUser($postValues)
81
+    {
82
+        $userObj = UserFactory::createUserFromPostValues($postValues);
83 83
 
84
-		$doesItExist = $this->getUserBySlug($userObj->slug);
85
-		if (!empty($doesItExist)) {
86
-			throw new \Exception('Trying to add username that already exists.');
87
-		}
88
-		$users = $this->repository->users;
89
-		$users[] = $userObj;
90
-		$this->repository->users = $users;
91
-		$this->save();
92
-	}
84
+        $doesItExist = $this->getUserBySlug($userObj->slug);
85
+        if (!empty($doesItExist)) {
86
+            throw new \Exception('Trying to add username that already exists.');
87
+        }
88
+        $users = $this->repository->users;
89
+        $users[] = $userObj;
90
+        $this->repository->users = $users;
91
+        $this->save();
92
+    }
93 93
 
94
-	/**
95
-	 * Delete user by slug
96
-	 *
97
-	 * @param $slug
98
-	 *
99
-	 * @throws \Exception
100
-	 */
101
-	public function deleteUserBySlug($slug)
102
-	{
103
-		$userToDelete = $this->getUserBySlug($slug);
104
-		if (empty($userToDelete)) {
105
-			throw new \Exception('Trying to delete a user that doesn\'t exist.');
106
-		}
107
-		$users = $this->getUsers();
108
-		foreach ($users as $key => $user) {
109
-			if ($user->slug == $userToDelete->slug) {
110
-				unset($users[$key]);
111
-				$this->repository->users = array_values($users);
112
-			}
113
-		}
114
-		$this->save();
115
-	}
94
+    /**
95
+     * Delete user by slug
96
+     *
97
+     * @param $slug
98
+     *
99
+     * @throws \Exception
100
+     */
101
+    public function deleteUserBySlug($slug)
102
+    {
103
+        $userToDelete = $this->getUserBySlug($slug);
104
+        if (empty($userToDelete)) {
105
+            throw new \Exception('Trying to delete a user that doesn\'t exist.');
106
+        }
107
+        $users = $this->getUsers();
108
+        foreach ($users as $key => $user) {
109
+            if ($user->slug == $userToDelete->slug) {
110
+                unset($users[$key]);
111
+                $this->repository->users = array_values($users);
112
+            }
113
+        }
114
+        $this->save();
115
+    }
116 116
 
117
-	/**
118
-	 * Get user by username
119
-	 *
120
-	 * @param $username
121
-	 *
122
-	 * @return array
123
-	 */
124
-	public function getUserByUsername($username)
125
-	{
126
-		$return = array();
117
+    /**
118
+     * Get user by username
119
+     *
120
+     * @param $username
121
+     *
122
+     * @return array
123
+     */
124
+    public function getUserByUsername($username)
125
+    {
126
+        $return = array();
127 127
 
128
-		$users = $this->repository->users;
129
-		foreach ($users as $user) {
130
-			if ($user->username == $username) {
131
-				$return = $user;
132
-				break;
133
-			}
134
-		}
128
+        $users = $this->repository->users;
129
+        foreach ($users as $user) {
130
+            if ($user->username == $username) {
131
+                $return = $user;
132
+                break;
133
+            }
134
+        }
135 135
 
136
-		return $return;
137
-	}
136
+        return $return;
137
+    }
138 138
 }
139 139
\ No newline at end of file
Please login to merge, or discard this patch.