@@ -17,6 +17,9 @@ |
||
17 | 17 | return self::run_row_query($query); |
18 | 18 | } |
19 | 19 | |
20 | + /** |
|
21 | + * @param string $date |
|
22 | + */ |
|
20 | 23 | public static function getTweetByFields($date, $text) |
21 | 24 | { |
22 | 25 | $query = "SELECT * FROM `jpemeric_stream`.`twitter` WHERE `date` = '{$date}' && `text` = '{$text}' LIMIT 1"; |
@@ -17,6 +17,9 @@ |
||
17 | 17 | return self::run_row_query($query); |
18 | 18 | } |
19 | 19 | |
20 | + /** |
|
21 | + * @param string $date |
|
22 | + */ |
|
20 | 23 | public static function getTweetByFields($date, $text) |
21 | 24 | { |
22 | 25 | $query = "SELECT * FROM `jpemeric_stream`.`twitter` WHERE `date` = '{$date}' && `text` = '{$text}' LIMIT 1"; |
@@ -17,6 +17,9 @@ |
||
17 | 17 | return self::run_row_query($query); |
18 | 18 | } |
19 | 19 | |
20 | + /** |
|
21 | + * @param string $date |
|
22 | + */ |
|
20 | 23 | public static function getTweetByFields($date, $text) |
21 | 24 | { |
22 | 25 | $query = "SELECT * FROM `jpemeric_stream`.`twitter` WHERE `date` = '{$date}' && `text` = '{$text}' LIMIT 1"; |
@@ -55,11 +55,11 @@ |
||
55 | 55 | final private function get_list_posts() |
56 | 56 | { |
57 | 57 | $post_array = array(); |
58 | - foreach($this->get_list_results() as $post) |
|
58 | + foreach ($this->get_list_results() as $post) |
|
59 | 59 | { |
60 | 60 | $post_array[] = $this->expand_post($post, 'full'); |
61 | 61 | } |
62 | - if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
62 | + if (count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
63 | 63 | $this->eject(); |
64 | 64 | return $post_array; |
65 | 65 | } |
@@ -59,8 +59,9 @@ |
||
59 | 59 | { |
60 | 60 | $post_array[] = $this->expand_post($post, 'full'); |
61 | 61 | } |
62 | - if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
63 | - $this->eject(); |
|
62 | + if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') { |
|
63 | + $this->eject(); |
|
64 | + } |
|
64 | 65 | return $post_array; |
65 | 66 | } |
66 | 67 |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | public function __construct() |
14 | 14 | { |
15 | - global $config; |
|
15 | + global $config; |
|
16 | 16 | $this->headers['From'] = self::$FROM; |
17 | 17 | $this->headers['Reply-To'] = "Jacob <{$config->admin_email}>"; |
18 | 18 | $this->headers['Bcc'] = "Jacob <{$config->admin_email}>"; |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | |
34 | 34 | private function process_form() |
35 | 35 | { |
36 | - if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
36 | + if (!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
37 | 37 | return (object) array('display' => 'normal'); |
38 | 38 | |
39 | 39 | Loader::load('utility', 'Validate'); |
40 | 40 | $error_result = array(); |
41 | - if(!Validate::checkRequest('post', 'name', 'string')) |
|
41 | + if (!Validate::checkRequest('post', 'name', 'string')) |
|
42 | 42 | $error_result['name'] = 'please enter your name'; |
43 | - if(!Validate::checkRequest('post', 'email', 'string')) |
|
43 | + if (!Validate::checkRequest('post', 'email', 'string')) |
|
44 | 44 | $error_result['email'] = 'please enter a valid email'; |
45 | - if(!Validate::checkRequest('post', 'message', 'string')) |
|
45 | + if (!Validate::checkRequest('post', 'message', 'string')) |
|
46 | 46 | $error_result['message'] = 'please write a message'; |
47 | 47 | |
48 | 48 | $values = (object) array( |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | 'email' => Request::getPost('email'), |
51 | 51 | 'message' => Request::getPost('message')); |
52 | 52 | |
53 | - if(count($error_result) > 0) |
|
53 | + if (count($error_result) > 0) |
|
54 | 54 | { |
55 | 55 | return (object) array( |
56 | 56 | 'display' => 'error', |
@@ -33,17 +33,21 @@ |
||
33 | 33 | |
34 | 34 | private function process_form() |
35 | 35 | { |
36 | - if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
37 | - return (object) array('display' => 'normal'); |
|
36 | + if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') { |
|
37 | + return (object) array('display' => 'normal'); |
|
38 | + } |
|
38 | 39 | |
39 | 40 | Loader::load('utility', 'Validate'); |
40 | 41 | $error_result = array(); |
41 | - if(!Validate::checkRequest('post', 'name', 'string')) |
|
42 | - $error_result['name'] = 'please enter your name'; |
|
43 | - if(!Validate::checkRequest('post', 'email', 'string')) |
|
44 | - $error_result['email'] = 'please enter a valid email'; |
|
45 | - if(!Validate::checkRequest('post', 'message', 'string')) |
|
46 | - $error_result['message'] = 'please write a message'; |
|
42 | + if(!Validate::checkRequest('post', 'name', 'string')) { |
|
43 | + $error_result['name'] = 'please enter your name'; |
|
44 | + } |
|
45 | + if(!Validate::checkRequest('post', 'email', 'string')) { |
|
46 | + $error_result['email'] = 'please enter a valid email'; |
|
47 | + } |
|
48 | + if(!Validate::checkRequest('post', 'message', 'string')) { |
|
49 | + $error_result['message'] = 'please write a message'; |
|
50 | + } |
|
47 | 51 | |
48 | 52 | $values = (object) array( |
49 | 53 | 'name' => Request::getPost('name'), |
@@ -20,6 +20,6 @@ |
||
20 | 20 | ) |
21 | 21 | ); |
22 | 22 | |
23 | -Router::route($redirect,$direct); |
|
23 | +Router::route($redirect, $direct); |
|
24 | 24 | |
25 | 25 | ?> |
26 | 26 | \ No newline at end of file |
@@ -13,7 +13,7 @@ |
||
13 | 13 | public function __construct() |
14 | 14 | { |
15 | 15 | $extendedPdo = $this->newExtendedPdo(); |
16 | - $this->connections = new ConnectionLocator(function () use ($extendedPdo) { |
|
16 | + $this->connections = new ConnectionLocator(function() use ($extendedPdo) { |
|
17 | 17 | return $extendedPdo; |
18 | 18 | }); |
19 | 19 | } |
@@ -8,21 +8,21 @@ discard block |
||
8 | 8 | class MysqlPostRepositoryTest extends \PHPUnit_Framework_TestCase |
9 | 9 | { |
10 | 10 | |
11 | - protected $connections; |
|
11 | + protected $connections; |
|
12 | 12 | |
13 | - public function __construct() |
|
14 | - { |
|
15 | - $extendedPdo = $this->newExtendedPdo(); |
|
16 | - $this->connections = new ConnectionLocator(function () use ($extendedPdo) { |
|
17 | - return $extendedPdo; |
|
18 | - }); |
|
19 | - } |
|
13 | + public function __construct() |
|
14 | + { |
|
15 | + $extendedPdo = $this->newExtendedPdo(); |
|
16 | + $this->connections = new ConnectionLocator(function () use ($extendedPdo) { |
|
17 | + return $extendedPdo; |
|
18 | + }); |
|
19 | + } |
|
20 | 20 | |
21 | - protected function newExtendedPdo() |
|
22 | - { |
|
23 | - $extendedPdo = new ExtendedPdo('sqlite::memory:'); |
|
24 | - $extendedPdo->exec('ATTACH DATABASE `jpemeric_blog.db` AS `jpemeric_blog`'); |
|
25 | - $extendedPdo->exec(" |
|
21 | + protected function newExtendedPdo() |
|
22 | + { |
|
23 | + $extendedPdo = new ExtendedPdo('sqlite::memory:'); |
|
24 | + $extendedPdo->exec('ATTACH DATABASE `jpemeric_blog.db` AS `jpemeric_blog`'); |
|
25 | + $extendedPdo->exec(" |
|
26 | 26 | CREATE TABLE IF NOT EXISTS `jpemeric_blog`.`post` ( |
27 | 27 | `id` integer PRIMARY KEY AUTOINCREMENT, |
28 | 28 | `title` varchar(60) NOT NULL, |
@@ -32,48 +32,48 @@ discard block |
||
32 | 32 | `body` text NOT NULL, |
33 | 33 | `display` integer NOT NULL |
34 | 34 | )" |
35 | - ); |
|
36 | - return $extendedPdo; |
|
37 | - } |
|
35 | + ); |
|
36 | + return $extendedPdo; |
|
37 | + } |
|
38 | 38 | |
39 | - public function newMysqlPostRepository() |
|
40 | - { |
|
41 | - return new MysqlPostRepository($this->connections); |
|
42 | - } |
|
39 | + public function newMysqlPostRepository() |
|
40 | + { |
|
41 | + return new MysqlPostRepository($this->connections); |
|
42 | + } |
|
43 | 43 | |
44 | - public function testFindByUri() |
|
45 | - { |
|
46 | - $test_post = array( |
|
47 | - 'title' => 'test title', |
|
48 | - 'path' => 'test-uri', |
|
49 | - 'category' => 'test', |
|
50 | - 'date' => date('Y-m-d H:i:s'), |
|
51 | - 'body' => 'test content', |
|
52 | - 'display' => 1 |
|
53 | - ); |
|
44 | + public function testFindByUri() |
|
45 | + { |
|
46 | + $test_post = array( |
|
47 | + 'title' => 'test title', |
|
48 | + 'path' => 'test-uri', |
|
49 | + 'category' => 'test', |
|
50 | + 'date' => date('Y-m-d H:i:s'), |
|
51 | + 'body' => 'test content', |
|
52 | + 'display' => 1 |
|
53 | + ); |
|
54 | 54 | |
55 | - $this->connections->getDefault()->perform(" |
|
55 | + $this->connections->getDefault()->perform(" |
|
56 | 56 | INSERT INTO jpemeric_blog.post |
57 | 57 | (title, path, category, date, body, display) |
58 | 58 | VALUES |
59 | 59 | (:title, :path, :category, :date, :body, :display)", |
60 | - $test_post); |
|
60 | + $test_post); |
|
61 | 61 | |
62 | - $post = $this->newMysqlPostRepository()->findByUri($test_post['path']); |
|
63 | - $this->assertSame($test_post['path'], $post['path']); |
|
64 | - } |
|
62 | + $post = $this->newMysqlPostRepository()->findByUri($test_post['path']); |
|
63 | + $this->assertSame($test_post['path'], $post['path']); |
|
64 | + } |
|
65 | 65 | |
66 | - public function testIsInstanceOfPostRepository() |
|
67 | - { |
|
68 | - $this->assertInstanceOf( |
|
69 | - 'Jacobemerick\Web\Domain\Blog\PostRepository', |
|
70 | - $this->newMysqlPostRepository() |
|
71 | - ); |
|
72 | - } |
|
66 | + public function testIsInstanceOfPostRepository() |
|
67 | + { |
|
68 | + $this->assertInstanceOf( |
|
69 | + 'Jacobemerick\Web\Domain\Blog\PostRepository', |
|
70 | + $this->newMysqlPostRepository() |
|
71 | + ); |
|
72 | + } |
|
73 | 73 | |
74 | - public static function tearDownAfterClass() |
|
75 | - { |
|
74 | + public static function tearDownAfterClass() |
|
75 | + { |
|
76 | 76 | // $this->connections->getDefault()->disconnect(); |
77 | - unlink('jpemeric_blog.db'); |
|
78 | - } |
|
77 | + unlink('jpemeric_blog.db'); |
|
78 | + } |
|
79 | 79 | } |
@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | interface PostRepository |
6 | 6 | { |
7 | - public function findByUri($uri); |
|
7 | + public function findByUri($uri); |
|
8 | 8 | } |
@@ -7,27 +7,27 @@ |
||
7 | 7 | class MysqlPostRepository implements PostRepository |
8 | 8 | { |
9 | 9 | |
10 | - protected $connections; |
|
10 | + protected $connections; |
|
11 | 11 | |
12 | - public function __construct(ConnectionLocator $connections) |
|
13 | - { |
|
14 | - $this->connections = $connections; |
|
15 | - } |
|
12 | + public function __construct(ConnectionLocator $connections) |
|
13 | + { |
|
14 | + $this->connections = $connections; |
|
15 | + } |
|
16 | 16 | |
17 | - // todo make this smarter - it should parse by category as well |
|
18 | - public function findByUri($uri) |
|
19 | - { |
|
20 | - $query = " |
|
17 | + // todo make this smarter - it should parse by category as well |
|
18 | + public function findByUri($uri) |
|
19 | + { |
|
20 | + $query = " |
|
21 | 21 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
22 | 22 | FROM `jpemeric_blog`.`post` |
23 | 23 | WHERE `path` = :uri AND `display` = '1' |
24 | 24 | LIMIT 1"; |
25 | - $bindings = array( |
|
26 | - 'uri' => $uri |
|
27 | - ); |
|
28 | - return $this |
|
29 | - ->connections |
|
30 | - ->getRead() |
|
31 | - ->fetchOne($query, $bindings); |
|
32 | - } |
|
25 | + $bindings = array( |
|
26 | + 'uri' => $uri |
|
27 | + ); |
|
28 | + return $this |
|
29 | + ->connections |
|
30 | + ->getRead() |
|
31 | + ->fetchOne($query, $bindings); |
|
32 | + } |
|
33 | 33 | } |