@@ -8,89 +8,89 @@ |
||
8 | 8 | class MysqlGithubRepository implements GithubRepositoryInterface |
9 | 9 | { |
10 | 10 | |
11 | - /** @var ConnectionLocator */ |
|
12 | - protected $connections; |
|
11 | + /** @var ConnectionLocator */ |
|
12 | + protected $connections; |
|
13 | 13 | |
14 | - /** |
|
15 | - * @param ConnectonLocator $connections |
|
16 | - */ |
|
17 | - public function __construct(ConnectionLocator $connections) |
|
18 | - { |
|
19 | - $this->connections = $connections; |
|
20 | - } |
|
14 | + /** |
|
15 | + * @param ConnectonLocator $connections |
|
16 | + */ |
|
17 | + public function __construct(ConnectionLocator $connections) |
|
18 | + { |
|
19 | + $this->connections = $connections; |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * @param integer $limit |
|
24 | - * @param integer $offset |
|
25 | - * |
|
26 | - * @return array|false |
|
27 | - */ |
|
28 | - public function getEvents($limit = null, $offset = 0) |
|
29 | - { |
|
30 | - $query = " |
|
22 | + /** |
|
23 | + * @param integer $limit |
|
24 | + * @param integer $offset |
|
25 | + * |
|
26 | + * @return array|false |
|
27 | + */ |
|
28 | + public function getEvents($limit = null, $offset = 0) |
|
29 | + { |
|
30 | + $query = " |
|
31 | 31 | SELECT `id`, `event_id`, `datetime` |
32 | 32 | FROM `jpemeric_stream`.`github` |
33 | 33 | ORDER BY `datetime` DESC"; |
34 | - if (!is_null($limit)) { |
|
35 | - $query .= " |
|
34 | + if (!is_null($limit)) { |
|
35 | + $query .= " |
|
36 | 36 | LIMIT {$offset}, {$limit}"; |
37 | - } |
|
37 | + } |
|
38 | 38 | |
39 | - return $this |
|
40 | - ->connections |
|
41 | - ->getRead() |
|
42 | - ->fetchAll($query); |
|
43 | - } |
|
39 | + return $this |
|
40 | + ->connections |
|
41 | + ->getRead() |
|
42 | + ->fetchAll($query); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param integer $eventId |
|
47 | - * |
|
48 | - * @return array|false |
|
49 | - */ |
|
50 | - public function getEventByEventId($eventId) |
|
51 | - { |
|
52 | - $query = " |
|
45 | + /** |
|
46 | + * @param integer $eventId |
|
47 | + * |
|
48 | + * @return array|false |
|
49 | + */ |
|
50 | + public function getEventByEventId($eventId) |
|
51 | + { |
|
52 | + $query = " |
|
53 | 53 | SELECT * |
54 | 54 | FROM `jpemeric_stream`.`github` |
55 | 55 | WHERE `event_id` = :event_id |
56 | 56 | LIMIT 1"; |
57 | 57 | |
58 | - $bindings = [ |
|
59 | - 'event_id' => $eventId, |
|
60 | - ]; |
|
58 | + $bindings = [ |
|
59 | + 'event_id' => $eventId, |
|
60 | + ]; |
|
61 | 61 | |
62 | - return $this |
|
63 | - ->connections |
|
64 | - ->getRead() |
|
65 | - ->fetchOne($query, $bindings); |
|
66 | - } |
|
62 | + return $this |
|
63 | + ->connections |
|
64 | + ->getRead() |
|
65 | + ->fetchOne($query, $bindings); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param integer $eventId |
|
70 | - * @param string $eventType |
|
71 | - * @param DateTime $datetime |
|
72 | - * @param array $metadata |
|
73 | - * |
|
74 | - * @return |
|
75 | - */ |
|
76 | - public function insertEvent($eventId, $eventType, DateTime $datetime, array $metadata) |
|
77 | - { |
|
78 | - $query = " |
|
68 | + /** |
|
69 | + * @param integer $eventId |
|
70 | + * @param string $eventType |
|
71 | + * @param DateTime $datetime |
|
72 | + * @param array $metadata |
|
73 | + * |
|
74 | + * @return |
|
75 | + */ |
|
76 | + public function insertEvent($eventId, $eventType, DateTime $datetime, array $metadata) |
|
77 | + { |
|
78 | + $query = " |
|
79 | 79 | INSERT INTO `jpemeric_stream`.`github` |
80 | 80 | (`event_id`, `type`, `datetime`, `metadata`) |
81 | 81 | VALUES |
82 | 82 | (:event_id, :event_type, :datetime, :metadata)"; |
83 | 83 | |
84 | - $bindings = [ |
|
85 | - 'event_id' => $eventId, |
|
86 | - 'event_type' => $eventType, |
|
87 | - 'datetime' => $datetime->format('Y-m-d H:i:s'), |
|
88 | - 'metadata' => json_encode($metadata), |
|
89 | - ]; |
|
84 | + $bindings = [ |
|
85 | + 'event_id' => $eventId, |
|
86 | + 'event_type' => $eventType, |
|
87 | + 'datetime' => $datetime->format('Y-m-d H:i:s'), |
|
88 | + 'metadata' => json_encode($metadata), |
|
89 | + ]; |
|
90 | 90 | |
91 | - return $this |
|
92 | - ->connections |
|
93 | - ->getWrite() |
|
94 | - ->perform($query, $bindings); |
|
95 | - } |
|
91 | + return $this |
|
92 | + ->connections |
|
93 | + ->getWrite() |
|
94 | + ->perform($query, $bindings); |
|
95 | + } |
|
96 | 96 | } |
@@ -7,108 +7,108 @@ |
||
7 | 7 | class MysqlActivityRepository implements ActivityRepositoryInterface |
8 | 8 | { |
9 | 9 | |
10 | - /** @var ConnectionLocator */ |
|
11 | - protected $connections; |
|
10 | + /** @var ConnectionLocator */ |
|
11 | + protected $connections; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @param ConnectonLocator $connections |
|
15 | - */ |
|
16 | - public function __construct(ConnectionLocator $connections) |
|
17 | - { |
|
18 | - $this->connections = $connections; |
|
19 | - } |
|
13 | + /** |
|
14 | + * @param ConnectonLocator $connections |
|
15 | + */ |
|
16 | + public function __construct(ConnectionLocator $connections) |
|
17 | + { |
|
18 | + $this->connections = $connections; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * @param integer $id |
|
23 | - * |
|
24 | - * @return array|false |
|
25 | - */ |
|
26 | - public function getActivityById($id) |
|
27 | - { |
|
28 | - $query = " |
|
21 | + /** |
|
22 | + * @param integer $id |
|
23 | + * |
|
24 | + * @return array|false |
|
25 | + */ |
|
26 | + public function getActivityById($id) |
|
27 | + { |
|
28 | + $query = " |
|
29 | 29 | SELECT * |
30 | 30 | FROM `jpemeric_stream`.`activity` |
31 | 31 | WHERE `id` = :id |
32 | 32 | LIMIT 1"; |
33 | - $bindings = [ |
|
34 | - 'id' => $id, |
|
35 | - ]; |
|
33 | + $bindings = [ |
|
34 | + 'id' => $id, |
|
35 | + ]; |
|
36 | 36 | |
37 | - return $this |
|
38 | - ->connections |
|
39 | - ->getRead() |
|
40 | - ->fetchOne($query, $bindings); |
|
41 | - } |
|
37 | + return $this |
|
38 | + ->connections |
|
39 | + ->getRead() |
|
40 | + ->fetchOne($query, $bindings); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param integer $limit |
|
45 | - * @param integer $offset |
|
46 | - * |
|
47 | - * @return array|false |
|
48 | - */ |
|
49 | - public function getActivities($limit = null, $offset = 0) |
|
50 | - { |
|
51 | - $query = " |
|
43 | + /** |
|
44 | + * @param integer $limit |
|
45 | + * @param integer $offset |
|
46 | + * |
|
47 | + * @return array|false |
|
48 | + */ |
|
49 | + public function getActivities($limit = null, $offset = 0) |
|
50 | + { |
|
51 | + $query = " |
|
52 | 52 | SELECT * |
53 | 53 | FROM `jpemeric_stream`.`activity` |
54 | 54 | ORDER BY `datetime` DESC"; |
55 | - if (!is_null($limit)) { |
|
56 | - $query .= " |
|
55 | + if (!is_null($limit)) { |
|
56 | + $query .= " |
|
57 | 57 | LIMIT {$offset}, {$limit}"; |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - return $this |
|
61 | - ->connections |
|
62 | - ->getRead() |
|
63 | - ->fetchAll($query); |
|
64 | - } |
|
60 | + return $this |
|
61 | + ->connections |
|
62 | + ->getRead() |
|
63 | + ->fetchAll($query); |
|
64 | + } |
|
65 | 65 | |
66 | - public function getActivitiesCount() |
|
67 | - { |
|
68 | - $query = " |
|
66 | + public function getActivitiesCount() |
|
67 | + { |
|
68 | + $query = " |
|
69 | 69 | SELECT COUNT(1) AS `count` |
70 | 70 | FROM `jpemeric_stream`.`activity`"; |
71 | 71 | |
72 | - return $this |
|
73 | - ->connections |
|
74 | - ->getRead() |
|
75 | - ->fetchValue($query); |
|
76 | - } |
|
72 | + return $this |
|
73 | + ->connections |
|
74 | + ->getRead() |
|
75 | + ->fetchValue($query); |
|
76 | + } |
|
77 | 77 | |
78 | - public function getActivitiesByType($type, $limit = null, $offset = 0) |
|
79 | - { |
|
80 | - $query = " |
|
78 | + public function getActivitiesByType($type, $limit = null, $offset = 0) |
|
79 | + { |
|
80 | + $query = " |
|
81 | 81 | SELECT * |
82 | 82 | FROM `jpemeric_stream`.`activity` |
83 | 83 | WHERE `type` = :type |
84 | 84 | ORDER BY `datetime` DESC"; |
85 | - if (!is_null($limit)) { |
|
86 | - $query .= " |
|
85 | + if (!is_null($limit)) { |
|
86 | + $query .= " |
|
87 | 87 | LIMIT {$offset}, {$limit}"; |
88 | - } |
|
89 | - $bindings = [ |
|
90 | - 'type' => $type, |
|
91 | - ]; |
|
88 | + } |
|
89 | + $bindings = [ |
|
90 | + 'type' => $type, |
|
91 | + ]; |
|
92 | 92 | |
93 | - return $this |
|
94 | - ->connections |
|
95 | - ->getRead() |
|
96 | - ->fetchAll($query, $bindings); |
|
97 | - } |
|
93 | + return $this |
|
94 | + ->connections |
|
95 | + ->getRead() |
|
96 | + ->fetchAll($query, $bindings); |
|
97 | + } |
|
98 | 98 | |
99 | - public function getActivitiesByTypeCount($type) |
|
100 | - { |
|
101 | - $query = " |
|
99 | + public function getActivitiesByTypeCount($type) |
|
100 | + { |
|
101 | + $query = " |
|
102 | 102 | SELECT COUNT(1) AS `count` |
103 | 103 | FROM `jpemeric_stream`.`activity` |
104 | 104 | WHERE `type` = :type"; |
105 | - $bindings = [ |
|
106 | - 'type' => $type, |
|
107 | - ]; |
|
105 | + $bindings = [ |
|
106 | + 'type' => $type, |
|
107 | + ]; |
|
108 | 108 | |
109 | - return $this |
|
110 | - ->connections |
|
111 | - ->getRead() |
|
112 | - ->fetchValue($query, $bindings); |
|
113 | - } |
|
109 | + return $this |
|
110 | + ->connections |
|
111 | + ->getRead() |
|
112 | + ->fetchValue($query, $bindings); |
|
113 | + } |
|
114 | 114 | } |
@@ -8,70 +8,70 @@ |
||
8 | 8 | class MysqlTwitterRepository implements TwitterRepositoryInterface |
9 | 9 | { |
10 | 10 | |
11 | - /** @var ConnectionLocator */ |
|
12 | - protected $connections; |
|
11 | + /** @var ConnectionLocator */ |
|
12 | + protected $connections; |
|
13 | 13 | |
14 | - /** |
|
15 | - * @param ConnectonLocator $connections |
|
16 | - */ |
|
17 | - public function __construct(ConnectionLocator $connections) |
|
18 | - { |
|
19 | - $this->connections = $connections; |
|
20 | - } |
|
14 | + /** |
|
15 | + * @param ConnectonLocator $connections |
|
16 | + */ |
|
17 | + public function __construct(ConnectionLocator $connections) |
|
18 | + { |
|
19 | + $this->connections = $connections; |
|
20 | + } |
|
21 | 21 | |
22 | - public function getTwitterByTweetId($tweetId) |
|
23 | - { |
|
24 | - $query = " |
|
22 | + public function getTwitterByTweetId($tweetId) |
|
23 | + { |
|
24 | + $query = " |
|
25 | 25 | SELECT `id`, `tweet_id`, `datetime`, `metadata` |
26 | 26 | FROM `jpemeric_stream`.`twitter` |
27 | 27 | WHERE `tweet_id` = :tweet_id |
28 | 28 | LIMIT 1"; |
29 | 29 | |
30 | - $bindings = [ |
|
31 | - 'tweet_id' => $tweetId, |
|
32 | - ]; |
|
30 | + $bindings = [ |
|
31 | + 'tweet_id' => $tweetId, |
|
32 | + ]; |
|
33 | 33 | |
34 | - return $this |
|
35 | - ->connections |
|
36 | - ->getRead() |
|
37 | - ->fetchOne($query, $bindings); |
|
38 | - } |
|
34 | + return $this |
|
35 | + ->connections |
|
36 | + ->getRead() |
|
37 | + ->fetchOne($query, $bindings); |
|
38 | + } |
|
39 | 39 | |
40 | - public function insertTweet($tweetId, DateTime $datetime, array $metadata) |
|
41 | - { |
|
42 | - $query = " |
|
40 | + public function insertTweet($tweetId, DateTime $datetime, array $metadata) |
|
41 | + { |
|
42 | + $query = " |
|
43 | 43 | INSERT INTO `jpemeric_stream`.`twitter` |
44 | 44 | (`tweet_id`, `datetime`, `metadata`) |
45 | 45 | VALUES |
46 | 46 | (:tweet_id, :datetime, :metadata)"; |
47 | 47 | |
48 | - $bindings = [ |
|
49 | - 'tweet_id' => $tweetId, |
|
50 | - 'datetime' => $datetime->format('Y-m-d H:i:s'), |
|
51 | - 'metadata' => json_encode($metadata), |
|
52 | - ]; |
|
48 | + $bindings = [ |
|
49 | + 'tweet_id' => $tweetId, |
|
50 | + 'datetime' => $datetime->format('Y-m-d H:i:s'), |
|
51 | + 'metadata' => json_encode($metadata), |
|
52 | + ]; |
|
53 | 53 | |
54 | - return $this |
|
55 | - ->connections |
|
56 | - ->getWrite() |
|
57 | - ->perform($query, $bindings); |
|
58 | - } |
|
54 | + return $this |
|
55 | + ->connections |
|
56 | + ->getWrite() |
|
57 | + ->perform($query, $bindings); |
|
58 | + } |
|
59 | 59 | |
60 | - public function updateTweetMetadata($tweetId, array $metadata) |
|
61 | - { |
|
62 | - $query = " |
|
60 | + public function updateTweetMetadata($tweetId, array $metadata) |
|
61 | + { |
|
62 | + $query = " |
|
63 | 63 | UPDATE `jpemeric_stream`.`twitter` |
64 | 64 | SET `metadata` = :metadata |
65 | 65 | WHERE `tweet_id` = :tweet_id"; |
66 | 66 | |
67 | - $bindings = [ |
|
68 | - 'metadata' => json_encode($metadata), |
|
69 | - 'tweet_id' => $tweetId, |
|
70 | - ]; |
|
67 | + $bindings = [ |
|
68 | + 'metadata' => json_encode($metadata), |
|
69 | + 'tweet_id' => $tweetId, |
|
70 | + ]; |
|
71 | 71 | |
72 | - return $this |
|
73 | - ->connections |
|
74 | - ->getWrite() |
|
75 | - ->perform($query, $bindings); |
|
76 | - } |
|
72 | + return $this |
|
73 | + ->connections |
|
74 | + ->getWrite() |
|
75 | + ->perform($query, $bindings); |
|
76 | + } |
|
77 | 77 | } |
@@ -8,73 +8,73 @@ |
||
8 | 8 | class MysqlYouTubeRepository implements YouTubeRepositoryInterface |
9 | 9 | { |
10 | 10 | |
11 | - /** @var ConnectionLocator */ |
|
12 | - protected $connections; |
|
11 | + /** @var ConnectionLocator */ |
|
12 | + protected $connections; |
|
13 | 13 | |
14 | - /** |
|
15 | - * @param ConnectonLocator $connections |
|
16 | - */ |
|
17 | - public function __construct(ConnectionLocator $connections) |
|
18 | - { |
|
19 | - $this->connections = $connections; |
|
20 | - } |
|
14 | + /** |
|
15 | + * @param ConnectonLocator $connections |
|
16 | + */ |
|
17 | + public function __construct(ConnectionLocator $connections) |
|
18 | + { |
|
19 | + $this->connections = $connections; |
|
20 | + } |
|
21 | 21 | |
22 | - public function getYouTubes($limit = null, $offset = 0) |
|
23 | - { |
|
24 | - $query = " |
|
22 | + public function getYouTubes($limit = null, $offset = 0) |
|
23 | + { |
|
24 | + $query = " |
|
25 | 25 | SELECT `id`, `video_id`, `datetime` |
26 | 26 | FROM `jpemeric_stream`.`youtube` |
27 | 27 | ORDER BY `datetime` DESC"; |
28 | - if (!is_null($limit)) { |
|
29 | - $query .= " |
|
28 | + if (!is_null($limit)) { |
|
29 | + $query .= " |
|
30 | 30 | LIMIT {$offset}, {$limit}"; |
31 | - } |
|
31 | + } |
|
32 | 32 | |
33 | - return $this |
|
34 | - ->connections |
|
35 | - ->getRead() |
|
36 | - ->fetchAll($query); |
|
37 | - } |
|
33 | + return $this |
|
34 | + ->connections |
|
35 | + ->getRead() |
|
36 | + ->fetchAll($query); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $title |
|
41 | - * |
|
42 | - * @return array|false |
|
43 | - */ |
|
44 | - public function getYouTubeByVideoId($videoId) |
|
45 | - { |
|
46 | - $query = " |
|
39 | + /** |
|
40 | + * @param string $title |
|
41 | + * |
|
42 | + * @return array|false |
|
43 | + */ |
|
44 | + public function getYouTubeByVideoId($videoId) |
|
45 | + { |
|
46 | + $query = " |
|
47 | 47 | SELECT * |
48 | 48 | FROM `jpemeric_stream`.`youtube` |
49 | 49 | WHERE `video_id` = :video_id |
50 | 50 | LIMIT 1"; |
51 | - $bindings = [ |
|
52 | - 'video_id' => $videoId, |
|
53 | - ]; |
|
51 | + $bindings = [ |
|
52 | + 'video_id' => $videoId, |
|
53 | + ]; |
|
54 | 54 | |
55 | - return $this |
|
56 | - ->connections |
|
57 | - ->getRead() |
|
58 | - ->fetchOne($query, $bindings); |
|
59 | - } |
|
55 | + return $this |
|
56 | + ->connections |
|
57 | + ->getRead() |
|
58 | + ->fetchOne($query, $bindings); |
|
59 | + } |
|
60 | 60 | |
61 | - public function insertVideo($videoId, DateTime $datetime, array $metadata) |
|
62 | - { |
|
63 | - $query = " |
|
61 | + public function insertVideo($videoId, DateTime $datetime, array $metadata) |
|
62 | + { |
|
63 | + $query = " |
|
64 | 64 | INSERT INTO `jpemeric_stream`.`youtube` |
65 | 65 | (`video_id`, `datetime`, `metadata`) |
66 | 66 | VALUES |
67 | 67 | (:video_id, :datetime, :metadata)"; |
68 | 68 | |
69 | - $bindings = [ |
|
70 | - 'video_id' => $videoId, |
|
71 | - 'datetime' => $datetime->format('Y-m-d H:i:s'), |
|
72 | - 'metadata' => json_encode($metadata), |
|
73 | - ]; |
|
69 | + $bindings = [ |
|
70 | + 'video_id' => $videoId, |
|
71 | + 'datetime' => $datetime->format('Y-m-d H:i:s'), |
|
72 | + 'metadata' => json_encode($metadata), |
|
73 | + ]; |
|
74 | 74 | |
75 | - return $this |
|
76 | - ->connections |
|
77 | - ->getWrite() |
|
78 | - ->perform($query, $bindings); |
|
79 | - } |
|
75 | + return $this |
|
76 | + ->connections |
|
77 | + ->getWrite() |
|
78 | + ->perform($query, $bindings); |
|
79 | + } |
|
80 | 80 | } |