Completed
Push — master ( ce03f9...989695 )
by Jacob
04:19
created
src/Domain/Stream/Blog/MysqlBlogRepository.php 1 patch
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -8,129 +8,129 @@
 block discarded – undo
8 8
 class MysqlBlogRepository implements BlogRepositoryInterface
9 9
 {
10 10
 
11
-    /** @var  ConnectionLocator */
12
-    protected $connections;
13
-
14
-    /**
15
-     * @param ConnectonLocator $connections
16
-     */
17
-    public function __construct(ConnectionLocator $connections)
18
-    {
19
-        $this->connections = $connections;
20
-    }
21
-
22
-    /**
23
-     * @param integer $id
24
-     *
25
-     * @return array|false
26
-     */
27
-    public function getBlogById($id)
28
-    {
29
-        $query = "
11
+	/** @var  ConnectionLocator */
12
+	protected $connections;
13
+
14
+	/**
15
+	 * @param ConnectonLocator $connections
16
+	 */
17
+	public function __construct(ConnectionLocator $connections)
18
+	{
19
+		$this->connections = $connections;
20
+	}
21
+
22
+	/**
23
+	 * @param integer $id
24
+	 *
25
+	 * @return array|false
26
+	 */
27
+	public function getBlogById($id)
28
+	{
29
+		$query = "
30 30
             SELECT *
31 31
             FROM `jpemeric_stream`.`blog`
32 32
             WHERE `id` = :id
33 33
             LIMIT 1";
34
-        $bindings = [
35
-            'id' => $id,
36
-        ];
37
-
38
-        return $this
39
-            ->connections
40
-            ->getRead()
41
-            ->fetchOne($query, $bindings);
42
-    }
43
-
44
-    public function getBlogByPermalink($permalink)
45
-    {
46
-        $query = "
34
+		$bindings = [
35
+			'id' => $id,
36
+		];
37
+
38
+		return $this
39
+			->connections
40
+			->getRead()
41
+			->fetchOne($query, $bindings);
42
+	}
43
+
44
+	public function getBlogByPermalink($permalink)
45
+	{
46
+		$query = "
47 47
             SELECT *
48 48
             FROM `jpemeric_stream`.`blog2`
49 49
             WHERE `permalink` = :permalink
50 50
             LIMIT 1";
51
-        $bindings = [
52
-            'permalink' => $permalink,
53
-        ];
54
-
55
-        return $this
56
-            ->connections
57
-            ->getRead()
58
-            ->fetchOne($query, $bindings);
59
-    }
60
-
61
-    /**
62
-     * @param string $title
63
-     *
64
-     * @return array|false
65
-     */
66
-    public function getBlogByTitle($title)
67
-    {
68
-        $query = "
51
+		$bindings = [
52
+			'permalink' => $permalink,
53
+		];
54
+
55
+		return $this
56
+			->connections
57
+			->getRead()
58
+			->fetchOne($query, $bindings);
59
+	}
60
+
61
+	/**
62
+	 * @param string $title
63
+	 *
64
+	 * @return array|false
65
+	 */
66
+	public function getBlogByTitle($title)
67
+	{
68
+		$query = "
69 69
             SELECT *
70 70
             FROM `jpemeric_stream`.`blog`
71 71
             WHERE `title` = :title
72 72
             LIMIT 1";
73
-        $bindings = [
74
-            'title' => $title,
75
-        ];
76
-
77
-        return $this
78
-            ->connections
79
-            ->getRead()
80
-            ->fetchOne($query, $bindings);
81
-    }
82
-
83
-    public function getBlogs($limit = null, $offset = 0)
84
-    {
85
-        $query = "
73
+		$bindings = [
74
+			'title' => $title,
75
+		];
76
+
77
+		return $this
78
+			->connections
79
+			->getRead()
80
+			->fetchOne($query, $bindings);
81
+	}
82
+
83
+	public function getBlogs($limit = null, $offset = 0)
84
+	{
85
+		$query = "
86 86
             SELECT `id`, `permalink`, `datetime`
87 87
             FROM `jpemeric_stream`.`blog2`
88 88
             ORDER BY `datetime` DESC";
89
-        if (!is_null($limit)) {
90
-            $query .= "
89
+		if (!is_null($limit)) {
90
+			$query .= "
91 91
             LIMIT {$limit}, {$offset}";
92
-        }
92
+		}
93 93
 
94
-        return $this
95
-            ->connections
96
-            ->getRead()
97
-            ->fetchAll($query);
98
-    }
94
+		return $this
95
+			->connections
96
+			->getRead()
97
+			->fetchAll($query);
98
+	}
99 99
 
100
-    public function getBlogsUpdatedSince(DateTime $datetime)
101
-    {
102
-        $query = "
100
+	public function getBlogsUpdatedSince(DateTime $datetime)
101
+	{
102
+		$query = "
103 103
             SELECT *
104 104
             FROM `jpemeric_stream`.`blog2`
105 105
             WHERE `updated_at` >= :last_update";
106 106
 
107
-        $bindings = [
108
-            'last_update' => $datetime->format('Y-m-d H:i:s'),
109
-        ];
107
+		$bindings = [
108
+			'last_update' => $datetime->format('Y-m-d H:i:s'),
109
+		];
110 110
 
111
-        return $this
112
-            ->connections
113
-            ->getRead()
114
-            ->fetchAll($query, $bindings);
115
-    }
111
+		return $this
112
+			->connections
113
+			->getRead()
114
+			->fetchAll($query, $bindings);
115
+	}
116 116
 
117
-    public function insertBlog($permalink, DateTime $datetime, array $metadata)
118
-    {
119
-        $query = "
117
+	public function insertBlog($permalink, DateTime $datetime, array $metadata)
118
+	{
119
+		$query = "
120 120
             INSERT INTO `jpemeric_stream`.`blog2`
121 121
                 (`permalink`, `datetime`, `metadata`)
122 122
             VALUES
123 123
                 (:permalink, :datetime, :metadata)";
124 124
 
125
-        $bindings = [
126
-            'permalink' => $permalink,
127
-            'datetime' => $datetime->format('Y-m-d H:i:s'),
128
-            'metadata' => json_encode($metadata),
129
-        ];
130
-
131
-        return $this
132
-            ->connections
133
-            ->getWrite()
134
-            ->perform($query, $bindings);
135
-    }
125
+		$bindings = [
126
+			'permalink' => $permalink,
127
+			'datetime' => $datetime->format('Y-m-d H:i:s'),
128
+			'metadata' => json_encode($metadata),
129
+		];
130
+
131
+		return $this
132
+			->connections
133
+			->getWrite()
134
+			->perform($query, $bindings);
135
+	}
136 136
 }
Please login to merge, or discard this patch.