Passed
Push — develop ( ecbe19...f5d3ab )
by Jens
02:58
created
cloudcontrol/library/storage/Document.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -18,58 +18,58 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class Document
20 20
 {
21
-    public $id;
22
-    public $path;
23
-    public $title;
24
-    public $slug;
25
-    public $type;
26
-    public $documentType;
27
-    public $documentTypeSlug;
28
-    public $state;
29
-    public $lastModificationDate;
30
-    public $creationDate;
31
-    public $lastModifiedBy;
32
-    protected $fields;
33
-    protected $bricks;
34
-    protected $dynamicBricks;
35
-    protected $content;
21
+	public $id;
22
+	public $path;
23
+	public $title;
24
+	public $slug;
25
+	public $type;
26
+	public $documentType;
27
+	public $documentTypeSlug;
28
+	public $state;
29
+	public $lastModificationDate;
30
+	public $creationDate;
31
+	public $lastModifiedBy;
32
+	protected $fields;
33
+	protected $bricks;
34
+	protected $dynamicBricks;
35
+	protected $content;
36 36
 
37
-    protected $dbHandle;
37
+	protected $dbHandle;
38 38
 
39
-    protected $jsonEncodedFields = array('fields', 'bricks', 'dynamicBricks');
40
-    protected $orderableFields = array('title', 'slug', 'type', 'documentType', 'documentTypeSlug', 'state', 'lastModificationDate', 'creationDate', 'lastModifiedBy');
39
+	protected $jsonEncodedFields = array('fields', 'bricks', 'dynamicBricks');
40
+	protected $orderableFields = array('title', 'slug', 'type', 'documentType', 'documentTypeSlug', 'state', 'lastModificationDate', 'creationDate', 'lastModifiedBy');
41 41
 
42
-    public function __get($name) {
43
-        if (in_array($name, $this->jsonEncodedFields)) {
44
-            if (is_string($this->$name)) {
45
-                return json_decode($this->$name);
46
-            } else {
47
-                return $this->$name;
48
-            }
49
-        } elseif ($name === 'content') {
50
-            if ($this->dbHandle === null) {
51
-                throw new \Exception('Document doesnt have a dbHandle handle. (path: ' . $this->path . ')');
52
-            } else {
53
-                if ($this->content === null) {
54
-                    return $this->getContent();
55
-                }
56
-            }
57
-        } elseif ($name === 'dbHandle') {
58
-            throw new \Exception('Trying to get protected property repository.');
59
-        }
60
-        return $this->$name;
61
-    }
42
+	public function __get($name) {
43
+		if (in_array($name, $this->jsonEncodedFields)) {
44
+			if (is_string($this->$name)) {
45
+				return json_decode($this->$name);
46
+			} else {
47
+				return $this->$name;
48
+			}
49
+		} elseif ($name === 'content') {
50
+			if ($this->dbHandle === null) {
51
+				throw new \Exception('Document doesnt have a dbHandle handle. (path: ' . $this->path . ')');
52
+			} else {
53
+				if ($this->content === null) {
54
+					return $this->getContent();
55
+				}
56
+			}
57
+		} elseif ($name === 'dbHandle') {
58
+			throw new \Exception('Trying to get protected property repository.');
59
+		}
60
+		return $this->$name;
61
+	}
62 62
 
63
-    public function __set($name, $value) {
64
-        if (in_array($name, $this->jsonEncodedFields)) {
65
-            $this->$name = json_encode($value);
66
-        } elseif ($name === 'content') {
67
-            // Dont do anything for now..
68
-            return;
69
-        }
63
+	public function __set($name, $value) {
64
+		if (in_array($name, $this->jsonEncodedFields)) {
65
+			$this->$name = json_encode($value);
66
+		} elseif ($name === 'content') {
67
+			// Dont do anything for now..
68
+			return;
69
+		}
70 70
 
71
-        $this->$name = $value;
72
-    }
71
+		$this->$name = $value;
72
+	}
73 73
 
74 74
 	/**
75 75
 	 * @param string $orderBy
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
 	 * @return array
79 79
 	 * @throws \Exception
80 80
 	 */
81
-    public function getContent($orderBy = 'title', $order = 'ASC')
82
-    {
83
-        $folderPathWithWildcard = $this->path . '%';
84
-        $sql = '    SELECT *
81
+	public function getContent($orderBy = 'title', $order = 'ASC')
82
+	{
83
+		$folderPathWithWildcard = $this->path . '%';
84
+		$sql = '    SELECT *
85 85
                       FROM documents
86 86
                      WHERE `path` LIKE ' . $this->dbHandle->quote($folderPathWithWildcard) . '
87 87
                        AND substr(`path`, ' . (strlen($this->path) + 2) . ') NOT LIKE "%/%"
@@ -89,24 +89,24 @@  discard block
 block discarded – undo
89 89
                        AND path != ' . $this->dbHandle->quote($this->path) . '
90 90
                   ORDER BY ' . (in_array($orderBy, $this->orderableFields) ? $orderBy : 'title') . ' ' . ($order === 'ASC' ? 'ASC' : 'DESC') . '
91 91
                     ';
92
-        $stmt = $this->dbHandle->prepare($sql);
92
+		$stmt = $this->dbHandle->prepare($sql);
93 93
 		if ($stmt === false) {
94 94
 			$errorInfo = $this->dbHandle->errorInfo();
95 95
 			$errorMsg = $errorInfo[2];
96 96
 			throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
97 97
 		}
98
-        $stmt->bindColumn(':orderBy', $orderBy, \PDO::PARAM_STMT);
98
+		$stmt->bindColumn(':orderBy', $orderBy, \PDO::PARAM_STMT);
99 99
 		$stmt->execute();
100
-        $contents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document');
101
-        foreach ($contents as $key => $document) {
102
-            if ($document->type === 'folder') {
103
-                $document->dbHandle = $this->dbHandle;
104
-                $contents[$key] = $document;
105
-            }
106
-        }
107
-        $this->content = $contents;
108
-        return $this->content;
109
-    }
100
+		$contents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document');
101
+		foreach ($contents as $key => $document) {
102
+			if ($document->type === 'folder') {
103
+				$document->dbHandle = $this->dbHandle;
104
+				$contents[$key] = $document;
105
+			}
106
+		}
107
+		$this->content = $contents;
108
+		return $this->content;
109
+	}
110 110
 
111 111
 	/**
112 112
 	 * @return string
Please login to merge, or discard this patch.