@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | interface LogRepositoryInterface |
6 | 6 | { |
7 | - public function getActiveLogs($limit = null, $offset= 0); |
|
7 | + public function getActiveLogs($limit = null, $offset = 0); |
|
8 | 8 | } |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace Jacobemerick\Web\Domain\Waterfall\Log; |
4 | 4 | |
5 | -interface LogRepositoryInterface |
|
6 | -{ |
|
5 | +interface LogRepositoryInterface |
|
6 | +{ |
|
7 | 7 | public function getActiveLogs($limit = null, $offset= 0); |
8 | 8 | } |
@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | interface WaterfallRepositoryInterface |
6 | 6 | { |
7 | - public function getWaterfalls($limit = null, $offset= 0); |
|
7 | + public function getWaterfalls($limit = null, $offset = 0); |
|
8 | 8 | } |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace Jacobemerick\Web\Domain\Waterfall\Waterfall; |
4 | 4 | |
5 | -interface WaterfallRepositoryInterface |
|
6 | -{ |
|
5 | +interface WaterfallRepositoryInterface |
|
6 | +{ |
|
7 | 7 | public function getWaterfalls($limit = null, $offset= 0); |
8 | 8 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | protected $connections; |
12 | 12 | |
13 | 13 | /** |
14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
14 | + * @param ConnectionLocator $connections |
|
15 | 15 | */ |
16 | 16 | public function __construct(ConnectionLocator $connections) |
17 | 17 | { |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | |
5 | 5 | use Aura\Sql\ConnectionLocator; |
6 | 6 | |
7 | -class MysqlCompanionRepository implements CompanionRepositoryInterface |
|
8 | -{ |
|
7 | +class MysqlCompanionRepository implements CompanionRepositoryInterface |
|
8 | +{ |
|
9 | 9 | |
10 | 10 | /** @var Aura\Sql\ConnectionLocator */ |
11 | 11 | protected $connections; |
@@ -13,13 +13,11 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @param Aura\Sql\ConnectionLocator $connections |
15 | 15 | */ |
16 | - public function __construct(ConnectionLocator $connections) |
|
17 | - { |
|
16 | + public function __construct(ConnectionLocator $connections) { |
|
18 | 17 | $this->connections = $connections; |
19 | 18 | } |
20 | 19 | |
21 | - public function getCompanionList() |
|
22 | - { |
|
20 | + public function getCompanionList() { |
|
23 | 21 | $query = " |
24 | 22 | SELECT `companion`.`name`, `companion`.`alias`, COUNT(1) AS `count` |
25 | 23 | FROM `jpemeric_waterfall`.`companion` |
@@ -11,7 +11,7 @@ |
||
11 | 11 | protected $connections; |
12 | 12 | |
13 | 13 | /** |
14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
14 | + * @param ConnectionLocator $connections |
|
15 | 15 | */ |
16 | 16 | public function __construct(ConnectionLocator $connections) |
17 | 17 | { |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | |
5 | 5 | use Aura\Sql\ConnectionLocator; |
6 | 6 | |
7 | -class MysqlCountyRepository implements CountyRepositoryInterface |
|
8 | -{ |
|
7 | +class MysqlCountyRepository implements CountyRepositoryInterface |
|
8 | +{ |
|
9 | 9 | |
10 | 10 | /** @var Aura\Sql\ConnectionLocator */ |
11 | 11 | protected $connections; |
@@ -13,13 +13,11 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @param Aura\Sql\ConnectionLocator $connections |
15 | 15 | */ |
16 | - public function __construct(ConnectionLocator $connections) |
|
17 | - { |
|
16 | + public function __construct(ConnectionLocator $connections) { |
|
18 | 17 | $this->connections = $connections; |
19 | 18 | } |
20 | 19 | |
21 | - public function getCountyList() |
|
22 | - { |
|
20 | + public function getCountyList() { |
|
23 | 21 | $query = " |
24 | 22 | SELECT `county`.`name`, `county`.`alias`, COUNT(1) AS `count` |
25 | 23 | FROM `jpemeric_waterfall`.`county` |
@@ -11,7 +11,7 @@ |
||
11 | 11 | protected $connections; |
12 | 12 | |
13 | 13 | /** |
14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
14 | + * @param ConnectionLocator $connections |
|
15 | 15 | */ |
16 | 16 | public function __construct(ConnectionLocator $connections) |
17 | 17 | { |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | |
5 | 5 | use Aura\Sql\ConnectionLocator; |
6 | 6 | |
7 | -class MysqlLogRepository implements LogRepositoryInterface |
|
8 | -{ |
|
7 | +class MysqlLogRepository implements LogRepositoryInterface |
|
8 | +{ |
|
9 | 9 | |
10 | 10 | /** @var Aura\Sql\ConnectionLocator */ |
11 | 11 | protected $connections; |
@@ -13,13 +13,11 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @param Aura\Sql\ConnectionLocator $connections |
15 | 15 | */ |
16 | - public function __construct(ConnectionLocator $connections) |
|
17 | - { |
|
16 | + public function __construct(ConnectionLocator $connections) { |
|
18 | 17 | $this->connections = $connections; |
19 | 18 | } |
20 | 19 | |
21 | - public function getActiveLogs($limit = null, $offset = 0) |
|
22 | - { |
|
20 | + public function getActiveLogs($limit = null, $offset = 0) { |
|
23 | 21 | $query = " |
24 | 22 | SELECT `id`, `title`, `alias`, `date`, `publish_date`, `introduction` |
25 | 23 | FROM `jpemeric_waterfall`.`log` |
@@ -11,7 +11,7 @@ |
||
11 | 11 | protected $connections; |
12 | 12 | |
13 | 13 | /** |
14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
14 | + * @param ConnectionLocator $connections |
|
15 | 15 | */ |
16 | 16 | public function __construct(ConnectionLocator $connections) |
17 | 17 | { |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | |
5 | 5 | use Aura\Sql\ConnectionLocator; |
6 | 6 | |
7 | -class MysqlPeriodRepository implements PeriodRepositoryInterface |
|
8 | -{ |
|
7 | +class MysqlPeriodRepository implements PeriodRepositoryInterface |
|
8 | +{ |
|
9 | 9 | |
10 | 10 | /** @var Aura\Sql\ConnectionLocator */ |
11 | 11 | protected $connections; |
@@ -13,13 +13,11 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @param Aura\Sql\ConnectionLocator $connections |
15 | 15 | */ |
16 | - public function __construct(ConnectionLocator $connections) |
|
17 | - { |
|
16 | + public function __construct(ConnectionLocator $connections) { |
|
18 | 17 | $this->connections = $connections; |
19 | 18 | } |
20 | 19 | |
21 | - public function getPeriodList() |
|
22 | - { |
|
20 | + public function getPeriodList() { |
|
23 | 21 | $query = " |
24 | 22 | SELECT `period`.`name`, `period`.`alias`, COUNT(1) AS `count` |
25 | 23 | FROM `jpemeric_waterfall`.`period` |
@@ -11,7 +11,7 @@ |
||
11 | 11 | protected $connections; |
12 | 12 | |
13 | 13 | /** |
14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
14 | + * @param ConnectionLocator $connections |
|
15 | 15 | */ |
16 | 16 | public function __construct(ConnectionLocator $connections) |
17 | 17 | { |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | |
5 | 5 | use Aura\Sql\ConnectionLocator; |
6 | 6 | |
7 | -class MysqlWatercourseRepository implements WatercourseRepositoryInterface |
|
8 | -{ |
|
7 | +class MysqlWatercourseRepository implements WatercourseRepositoryInterface |
|
8 | +{ |
|
9 | 9 | |
10 | 10 | /** @var Aura\Sql\ConnectionLocator */ |
11 | 11 | protected $connections; |
@@ -13,14 +13,12 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @param Aura\Sql\ConnectionLocator $connections |
15 | 15 | */ |
16 | - public function __construct(ConnectionLocator $connections) |
|
17 | - { |
|
16 | + public function __construct(ConnectionLocator $connections) { |
|
18 | 17 | $this->connections = $connections; |
19 | 18 | } |
20 | 19 | |
21 | 20 | // todo wot are you even serious |
22 | - public function getWatercourseList() |
|
23 | - { |
|
21 | + public function getWatercourseList() { |
|
24 | 22 | $query = " |
25 | 23 | SELECT `sum_table`.`name`, `sum_table`.`alias`, SUM(`count`) AS `count` |
26 | 24 | FROM (( |
@@ -59,6 +59,9 @@ discard block |
||
59 | 59 | $this->add_posts($youtube_result, 'youtube'); |
60 | 60 | } |
61 | 61 | |
62 | + /** |
|
63 | + * @param string $type |
|
64 | + */ |
|
62 | 65 | private function remove_existing($result, $type) |
63 | 66 | { |
64 | 67 | foreach($result as $key => $row) |
@@ -70,6 +73,9 @@ discard block |
||
70 | 73 | return $result; |
71 | 74 | } |
72 | 75 | |
76 | + /** |
|
77 | + * @param string $type |
|
78 | + */ |
|
73 | 79 | private function add_posts($result, $type) |
74 | 80 | { |
75 | 81 | foreach($result as $row) |
@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | |
18 | 18 | public static function instance() |
19 | 19 | { |
20 | - if(!isset(self::$instance)) |
|
20 | + if (!isset(self::$instance)) |
|
21 | 21 | self::$instance = new Loader(); |
22 | 22 | return self::$instance; |
23 | 23 | } |
24 | 24 | |
25 | 25 | private function get_root() |
26 | 26 | { |
27 | - if(!isset($this->root)) |
|
27 | + if (!isset($this->root)) |
|
28 | 28 | { |
29 | 29 | $current_directory = dirname(__FILE__); |
30 | 30 | $current_directory = substr($current_directory, 0, -7); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | private static function get_extension($type) |
54 | 54 | { |
55 | - switch($type) |
|
55 | + switch ($type) |
|
56 | 56 | { |
57 | 57 | case 'collector' : |
58 | 58 | case 'controller' : |
@@ -104,15 +104,15 @@ discard block |
||
104 | 104 | |
105 | 105 | public static function load($type, $files, $data = array()) |
106 | 106 | { |
107 | - foreach((array) $files as $file) |
|
107 | + foreach ((array) $files as $file) |
|
108 | 108 | { |
109 | 109 | $file_path = self::instance()->get_path($type, $file); |
110 | - if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
110 | + if (in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
111 | 111 | continue; |
112 | 112 | |
113 | 113 | self::instance()->add_included_file($file_path); |
114 | 114 | |
115 | - switch($type) |
|
115 | + switch ($type) |
|
116 | 116 | { |
117 | 117 | case 'images' : |
118 | 118 | case 'scripts' : |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | $reflectionObject = self::create_reflection_class($file); |
144 | 144 | |
145 | - if( |
|
145 | + if ( |
|
146 | 146 | $reflectionObject->hasMethod('instance') && |
147 | 147 | $reflectionObject->getMethod('instance')->isStatic()) |
148 | 148 | { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | $reflectionObject = self::create_reflection_class($file); |
159 | 159 | |
160 | - if($reflectionObject->hasMethod('__construct')) |
|
160 | + if ($reflectionObject->hasMethod('__construct')) |
|
161 | 161 | return $reflectionObject->newInstanceArgs($data); |
162 | 162 | else |
163 | 163 | return $reflectionObject->newInstance(); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | if ($site == 'waterfalls' && self::instance()->is_live) { |
181 | 181 | return "{$protocol}://www.waterfallsofthekeweenaw.com/"; |
182 | 182 | } else { |
183 | - return $protocol . '://' . (self::instance()->is_live ? '' : 'dev.') . $site . '.jacobemerick.com/'; |
|
183 | + return $protocol.'://'.(self::instance()->is_live ? '' : 'dev.').$site.'.jacobemerick.com/'; |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | return '/'; |
@@ -3,175 +3,175 @@ |
||
3 | 3 | final class Loader |
4 | 4 | { |
5 | 5 | |
6 | - private $root; |
|
7 | - private $is_live; |
|
8 | - private $included_files = array(); |
|
9 | - |
|
10 | - private static $instance; |
|
11 | - |
|
12 | - private function __construct() |
|
13 | - { |
|
14 | - $this->is_live = (isset($_SERVER['HTTP_HOST']) && substr($_SERVER['HTTP_HOST'], 0, 4) !== 'dev.'); |
|
15 | - return $this; |
|
16 | - } |
|
17 | - |
|
18 | - public static function instance() |
|
19 | - { |
|
20 | - if(!isset(self::$instance)) |
|
21 | - self::$instance = new Loader(); |
|
22 | - return self::$instance; |
|
23 | - } |
|
24 | - |
|
25 | - private function get_root() |
|
26 | - { |
|
27 | - if(!isset($this->root)) |
|
28 | - { |
|
29 | - $current_directory = dirname(__FILE__); |
|
30 | - $current_directory = substr($current_directory, 0, -7); |
|
31 | - $this->root = $current_directory; |
|
32 | - } |
|
6 | + private $root; |
|
7 | + private $is_live; |
|
8 | + private $included_files = array(); |
|
9 | + |
|
10 | + private static $instance; |
|
11 | + |
|
12 | + private function __construct() |
|
13 | + { |
|
14 | + $this->is_live = (isset($_SERVER['HTTP_HOST']) && substr($_SERVER['HTTP_HOST'], 0, 4) !== 'dev.'); |
|
15 | + return $this; |
|
16 | + } |
|
17 | + |
|
18 | + public static function instance() |
|
19 | + { |
|
20 | + if(!isset(self::$instance)) |
|
21 | + self::$instance = new Loader(); |
|
22 | + return self::$instance; |
|
23 | + } |
|
24 | + |
|
25 | + private function get_root() |
|
26 | + { |
|
27 | + if(!isset($this->root)) |
|
28 | + { |
|
29 | + $current_directory = dirname(__FILE__); |
|
30 | + $current_directory = substr($current_directory, 0, -7); |
|
31 | + $this->root = $current_directory; |
|
32 | + } |
|
33 | 33 | |
34 | - return $this->root; |
|
35 | - } |
|
36 | - |
|
37 | - private function get_delimiter() |
|
38 | - { |
|
39 | - return (true || $this->is_live) ? '/' : '\\'; |
|
40 | - } |
|
41 | - |
|
42 | - private function check_delimiters($path) |
|
43 | - { |
|
44 | - return (true || $this->is_live) ? $path : str_replace('/', '\\', $path); |
|
45 | - } |
|
46 | - |
|
47 | - private static function get_class_name($path) |
|
48 | - { |
|
49 | - $path_array = explode('/', $path); |
|
50 | - return array_pop($path_array); |
|
51 | - } |
|
52 | - |
|
53 | - private static function get_extension($type) |
|
54 | - { |
|
55 | - switch($type) |
|
56 | - { |
|
57 | - case 'collector' : |
|
58 | - case 'controller' : |
|
59 | - case 'model' : |
|
60 | - case 'module' : |
|
61 | - case 'router' : |
|
62 | - case 'utility' : |
|
63 | - $extension = '.class.inc.php'; |
|
64 | - break; |
|
65 | - case 'view' : |
|
66 | - $extension = '.tpl.php'; |
|
67 | - break; |
|
68 | - } |
|
69 | - return $extension; |
|
70 | - } |
|
71 | - |
|
72 | - public static function getImagePath($type, $file) |
|
73 | - { |
|
74 | - $path = self::instance()->get_root(); |
|
75 | - $path .= 'public'; |
|
76 | - $path .= self::instance()->get_delimiter(); |
|
77 | - $path .= $type; |
|
78 | - $path .= self::instance()->get_delimiter(); |
|
79 | - $path .= self::instance()->check_delimiters($file); |
|
34 | + return $this->root; |
|
35 | + } |
|
36 | + |
|
37 | + private function get_delimiter() |
|
38 | + { |
|
39 | + return (true || $this->is_live) ? '/' : '\\'; |
|
40 | + } |
|
41 | + |
|
42 | + private function check_delimiters($path) |
|
43 | + { |
|
44 | + return (true || $this->is_live) ? $path : str_replace('/', '\\', $path); |
|
45 | + } |
|
46 | + |
|
47 | + private static function get_class_name($path) |
|
48 | + { |
|
49 | + $path_array = explode('/', $path); |
|
50 | + return array_pop($path_array); |
|
51 | + } |
|
52 | + |
|
53 | + private static function get_extension($type) |
|
54 | + { |
|
55 | + switch($type) |
|
56 | + { |
|
57 | + case 'collector' : |
|
58 | + case 'controller' : |
|
59 | + case 'model' : |
|
60 | + case 'module' : |
|
61 | + case 'router' : |
|
62 | + case 'utility' : |
|
63 | + $extension = '.class.inc.php'; |
|
64 | + break; |
|
65 | + case 'view' : |
|
66 | + $extension = '.tpl.php'; |
|
67 | + break; |
|
68 | + } |
|
69 | + return $extension; |
|
70 | + } |
|
71 | + |
|
72 | + public static function getImagePath($type, $file) |
|
73 | + { |
|
74 | + $path = self::instance()->get_root(); |
|
75 | + $path .= 'public'; |
|
76 | + $path .= self::instance()->get_delimiter(); |
|
77 | + $path .= $type; |
|
78 | + $path .= self::instance()->get_delimiter(); |
|
79 | + $path .= self::instance()->check_delimiters($file); |
|
80 | 80 | |
81 | - return $path; |
|
82 | - } |
|
83 | - |
|
84 | - private static function get_path($type, $file) |
|
85 | - { |
|
86 | - $path = self::instance()->get_root(); |
|
87 | - $path .= $type; |
|
88 | - $path .= self::instance()->get_delimiter(); |
|
89 | - $path .= self::instance()->check_delimiters($file); |
|
90 | - $path .= self::get_extension($type); |
|
81 | + return $path; |
|
82 | + } |
|
83 | + |
|
84 | + private static function get_path($type, $file) |
|
85 | + { |
|
86 | + $path = self::instance()->get_root(); |
|
87 | + $path .= $type; |
|
88 | + $path .= self::instance()->get_delimiter(); |
|
89 | + $path .= self::instance()->check_delimiters($file); |
|
90 | + $path .= self::get_extension($type); |
|
91 | 91 | |
92 | - return $path; |
|
93 | - } |
|
94 | - |
|
95 | - private function get_included_files() |
|
96 | - { |
|
97 | - return $this->included_files; |
|
98 | - } |
|
99 | - |
|
100 | - private function add_included_file($path) |
|
101 | - { |
|
102 | - $this->included_files[] = $path; |
|
103 | - } |
|
104 | - |
|
105 | - public static function load($type, $files, $data = array()) |
|
106 | - { |
|
107 | - foreach((array) $files as $file) |
|
108 | - { |
|
109 | - $file_path = self::instance()->get_path($type, $file); |
|
110 | - if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
111 | - continue; |
|
92 | + return $path; |
|
93 | + } |
|
94 | + |
|
95 | + private function get_included_files() |
|
96 | + { |
|
97 | + return $this->included_files; |
|
98 | + } |
|
99 | + |
|
100 | + private function add_included_file($path) |
|
101 | + { |
|
102 | + $this->included_files[] = $path; |
|
103 | + } |
|
104 | + |
|
105 | + public static function load($type, $files, $data = array()) |
|
106 | + { |
|
107 | + foreach((array) $files as $file) |
|
108 | + { |
|
109 | + $file_path = self::instance()->get_path($type, $file); |
|
110 | + if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
111 | + continue; |
|
112 | 112 | |
113 | - self::instance()->add_included_file($file_path); |
|
113 | + self::instance()->add_included_file($file_path); |
|
114 | 114 | |
115 | - switch($type) |
|
116 | - { |
|
117 | - case 'images' : |
|
118 | - case 'scripts' : |
|
119 | - case 'styles' : |
|
120 | - echo file_get_contents($file_path); |
|
121 | - break; |
|
122 | - case 'view' : |
|
123 | - extract($data); |
|
124 | - include($file_path); |
|
125 | - break; |
|
126 | - default : |
|
127 | - include_once($file_path); |
|
128 | - break; |
|
129 | - } |
|
130 | - } |
|
131 | - } |
|
132 | - |
|
133 | - private static function create_reflection_class($file) |
|
134 | - { |
|
135 | - $class_name = self::instance()->get_class_name($file); |
|
136 | - return new ReflectionClass($class_name); |
|
137 | - } |
|
138 | - |
|
139 | - public static function loadInstance($type, $file) |
|
140 | - { |
|
141 | - self::load($type, $file); |
|
115 | + switch($type) |
|
116 | + { |
|
117 | + case 'images' : |
|
118 | + case 'scripts' : |
|
119 | + case 'styles' : |
|
120 | + echo file_get_contents($file_path); |
|
121 | + break; |
|
122 | + case 'view' : |
|
123 | + extract($data); |
|
124 | + include($file_path); |
|
125 | + break; |
|
126 | + default : |
|
127 | + include_once($file_path); |
|
128 | + break; |
|
129 | + } |
|
130 | + } |
|
131 | + } |
|
132 | + |
|
133 | + private static function create_reflection_class($file) |
|
134 | + { |
|
135 | + $class_name = self::instance()->get_class_name($file); |
|
136 | + return new ReflectionClass($class_name); |
|
137 | + } |
|
138 | + |
|
139 | + public static function loadInstance($type, $file) |
|
140 | + { |
|
141 | + self::load($type, $file); |
|
142 | 142 | |
143 | - $reflectionObject = self::create_reflection_class($file); |
|
143 | + $reflectionObject = self::create_reflection_class($file); |
|
144 | 144 | |
145 | - if( |
|
146 | - $reflectionObject->hasMethod('instance') && |
|
147 | - $reflectionObject->getMethod('instance')->isStatic()) |
|
148 | - { |
|
149 | - return $reflectionObject->getMethod('instance')->invoke(null); |
|
150 | - } |
|
151 | - trigger_error("Requested class cannot be instance'd: {$type}, {$file}"); |
|
152 | - } |
|
153 | - |
|
154 | - public static function loadNew($type, $file, $data = array()) |
|
155 | - { |
|
156 | - self::load($type, $file); |
|
145 | + if( |
|
146 | + $reflectionObject->hasMethod('instance') && |
|
147 | + $reflectionObject->getMethod('instance')->isStatic()) |
|
148 | + { |
|
149 | + return $reflectionObject->getMethod('instance')->invoke(null); |
|
150 | + } |
|
151 | + trigger_error("Requested class cannot be instance'd: {$type}, {$file}"); |
|
152 | + } |
|
153 | + |
|
154 | + public static function loadNew($type, $file, $data = array()) |
|
155 | + { |
|
156 | + self::load($type, $file); |
|
157 | 157 | |
158 | - $reflectionObject = self::create_reflection_class($file); |
|
158 | + $reflectionObject = self::create_reflection_class($file); |
|
159 | 159 | |
160 | - if($reflectionObject->hasMethod('__construct')) |
|
161 | - return $reflectionObject->newInstanceArgs($data); |
|
162 | - else |
|
163 | - return $reflectionObject->newInstance(); |
|
164 | - } |
|
165 | - |
|
166 | - public static function getRoot() |
|
167 | - { |
|
168 | - return self::instance()->get_root(); |
|
169 | - } |
|
170 | - |
|
171 | - public static function isLive() |
|
172 | - { |
|
173 | - return self::instance()->is_live; |
|
174 | - } |
|
160 | + if($reflectionObject->hasMethod('__construct')) |
|
161 | + return $reflectionObject->newInstanceArgs($data); |
|
162 | + else |
|
163 | + return $reflectionObject->newInstance(); |
|
164 | + } |
|
165 | + |
|
166 | + public static function getRoot() |
|
167 | + { |
|
168 | + return self::instance()->get_root(); |
|
169 | + } |
|
170 | + |
|
171 | + public static function isLive() |
|
172 | + { |
|
173 | + return self::instance()->is_live; |
|
174 | + } |
|
175 | 175 | |
176 | 176 | public static function getRootURL($site = '') |
177 | 177 | { |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -final class Loader |
|
4 | -{ |
|
3 | +final class Loader |
|
4 | +{ |
|
5 | 5 | |
6 | 6 | private $root; |
7 | 7 | private $is_live; |
@@ -9,21 +9,19 @@ discard block |
||
9 | 9 | |
10 | 10 | private static $instance; |
11 | 11 | |
12 | - private function __construct() |
|
13 | - { |
|
12 | + private function __construct() { |
|
14 | 13 | $this->is_live = (isset($_SERVER['HTTP_HOST']) && substr($_SERVER['HTTP_HOST'], 0, 4) !== 'dev.'); |
15 | 14 | return $this; |
16 | 15 | } |
17 | 16 | |
18 | - public static function instance() |
|
19 | - { |
|
20 | - if(!isset(self::$instance)) |
|
21 | - self::$instance = new Loader(); |
|
17 | + public static function instance() { |
|
18 | + if(!isset(self::$instance)) { |
|
19 | + self::$instance = new Loader(); |
|
20 | + } |
|
22 | 21 | return self::$instance; |
23 | 22 | } |
24 | 23 | |
25 | - private function get_root() |
|
26 | - { |
|
24 | + private function get_root() { |
|
27 | 25 | if(!isset($this->root)) |
28 | 26 | { |
29 | 27 | $current_directory = dirname(__FILE__); |
@@ -34,24 +32,20 @@ discard block |
||
34 | 32 | return $this->root; |
35 | 33 | } |
36 | 34 | |
37 | - private function get_delimiter() |
|
38 | - { |
|
35 | + private function get_delimiter() { |
|
39 | 36 | return (true || $this->is_live) ? '/' : '\\'; |
40 | 37 | } |
41 | 38 | |
42 | - private function check_delimiters($path) |
|
43 | - { |
|
39 | + private function check_delimiters($path) { |
|
44 | 40 | return (true || $this->is_live) ? $path : str_replace('/', '\\', $path); |
45 | 41 | } |
46 | 42 | |
47 | - private static function get_class_name($path) |
|
48 | - { |
|
43 | + private static function get_class_name($path) { |
|
49 | 44 | $path_array = explode('/', $path); |
50 | 45 | return array_pop($path_array); |
51 | 46 | } |
52 | 47 | |
53 | - private static function get_extension($type) |
|
54 | - { |
|
48 | + private static function get_extension($type) { |
|
55 | 49 | switch($type) |
56 | 50 | { |
57 | 51 | case 'collector' : |
@@ -69,8 +63,7 @@ discard block |
||
69 | 63 | return $extension; |
70 | 64 | } |
71 | 65 | |
72 | - public static function getImagePath($type, $file) |
|
73 | - { |
|
66 | + public static function getImagePath($type, $file) { |
|
74 | 67 | $path = self::instance()->get_root(); |
75 | 68 | $path .= 'public'; |
76 | 69 | $path .= self::instance()->get_delimiter(); |
@@ -81,8 +74,7 @@ discard block |
||
81 | 74 | return $path; |
82 | 75 | } |
83 | 76 | |
84 | - private static function get_path($type, $file) |
|
85 | - { |
|
77 | + private static function get_path($type, $file) { |
|
86 | 78 | $path = self::instance()->get_root(); |
87 | 79 | $path .= $type; |
88 | 80 | $path .= self::instance()->get_delimiter(); |
@@ -92,23 +84,21 @@ discard block |
||
92 | 84 | return $path; |
93 | 85 | } |
94 | 86 | |
95 | - private function get_included_files() |
|
96 | - { |
|
87 | + private function get_included_files() { |
|
97 | 88 | return $this->included_files; |
98 | 89 | } |
99 | 90 | |
100 | - private function add_included_file($path) |
|
101 | - { |
|
91 | + private function add_included_file($path) { |
|
102 | 92 | $this->included_files[] = $path; |
103 | 93 | } |
104 | 94 | |
105 | - public static function load($type, $files, $data = array()) |
|
106 | - { |
|
95 | + public static function load($type, $files, $data = array()) { |
|
107 | 96 | foreach((array) $files as $file) |
108 | 97 | { |
109 | 98 | $file_path = self::instance()->get_path($type, $file); |
110 | - if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
111 | - continue; |
|
99 | + if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') { |
|
100 | + continue; |
|
101 | + } |
|
112 | 102 | |
113 | 103 | self::instance()->add_included_file($file_path); |
114 | 104 | |
@@ -130,14 +120,12 @@ discard block |
||
130 | 120 | } |
131 | 121 | } |
132 | 122 | |
133 | - private static function create_reflection_class($file) |
|
134 | - { |
|
123 | + private static function create_reflection_class($file) { |
|
135 | 124 | $class_name = self::instance()->get_class_name($file); |
136 | 125 | return new ReflectionClass($class_name); |
137 | 126 | } |
138 | 127 | |
139 | - public static function loadInstance($type, $file) |
|
140 | - { |
|
128 | + public static function loadInstance($type, $file) { |
|
141 | 129 | self::load($type, $file); |
142 | 130 | |
143 | 131 | $reflectionObject = self::create_reflection_class($file); |
@@ -151,30 +139,27 @@ discard block |
||
151 | 139 | trigger_error("Requested class cannot be instance'd: {$type}, {$file}"); |
152 | 140 | } |
153 | 141 | |
154 | - public static function loadNew($type, $file, $data = array()) |
|
155 | - { |
|
142 | + public static function loadNew($type, $file, $data = array()) { |
|
156 | 143 | self::load($type, $file); |
157 | 144 | |
158 | 145 | $reflectionObject = self::create_reflection_class($file); |
159 | 146 | |
160 | - if($reflectionObject->hasMethod('__construct')) |
|
161 | - return $reflectionObject->newInstanceArgs($data); |
|
162 | - else |
|
163 | - return $reflectionObject->newInstance(); |
|
147 | + if($reflectionObject->hasMethod('__construct')) { |
|
148 | + return $reflectionObject->newInstanceArgs($data); |
|
149 | + } else { |
|
150 | + return $reflectionObject->newInstance(); |
|
151 | + } |
|
164 | 152 | } |
165 | 153 | |
166 | - public static function getRoot() |
|
167 | - { |
|
154 | + public static function getRoot() { |
|
168 | 155 | return self::instance()->get_root(); |
169 | 156 | } |
170 | 157 | |
171 | - public static function isLive() |
|
172 | - { |
|
158 | + public static function isLive() { |
|
173 | 159 | return self::instance()->is_live; |
174 | 160 | } |
175 | 161 | |
176 | - public static function getRootURL($site = '') |
|
177 | - { |
|
162 | + public static function getRootURL($site = '') { |
|
178 | 163 | if (strlen($site) > 0) { |
179 | 164 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
180 | 165 | if ($site == 'waterfalls' && self::instance()->is_live) { |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | protected $connections; |
12 | 12 | |
13 | 13 | /** |
14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
14 | + * @param ConnectionLocator $connections |
|
15 | 15 | */ |
16 | 16 | public function __construct(ConnectionLocator $connections) |
17 | 17 | { |
@@ -41,6 +41,9 @@ discard block |
||
41 | 41 | ->fetchOne($query, $bindings); |
42 | 42 | } |
43 | 43 | |
44 | + /** |
|
45 | + * @param integer $limit |
|
46 | + */ |
|
44 | 47 | public function getActivePosts($limit = null, $offset = 0) |
45 | 48 | { |
46 | 49 | $query = " |
@@ -79,6 +82,9 @@ discard block |
||
79 | 82 | ->fetchValue($query, $bindings); |
80 | 83 | } |
81 | 84 | |
85 | + /** |
|
86 | + * @param integer $limit |
|
87 | + */ |
|
82 | 88 | public function getActivePostsByTag($tag, $limit = null, $offset = 0) |
83 | 89 | { |
84 | 90 | $query = " |
@@ -122,6 +128,9 @@ discard block |
||
122 | 128 | ->fetchValue($query, $bindings); |
123 | 129 | } |
124 | 130 | |
131 | + /** |
|
132 | + * @param integer $limit |
|
133 | + */ |
|
125 | 134 | public function getActivePostsByCategory($category, $limit = null, $offset = 0) |
126 | 135 | { |
127 | 136 | $query = " |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | |
5 | 5 | use Aura\Sql\ConnectionLocator; |
6 | 6 | |
7 | -class MysqlPostRepository implements PostRepositoryInterface |
|
8 | -{ |
|
7 | +class MysqlPostRepository implements PostRepositoryInterface |
|
8 | +{ |
|
9 | 9 | |
10 | 10 | /** @var Aura\Sql\ConnectionLocator */ |
11 | 11 | protected $connections; |
@@ -13,8 +13,7 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @param Aura\Sql\ConnectionLocator $connections |
15 | 15 | */ |
16 | - public function __construct(ConnectionLocator $connections) |
|
17 | - { |
|
16 | + public function __construct(ConnectionLocator $connections) { |
|
18 | 17 | $this->connections = $connections; |
19 | 18 | } |
20 | 19 | |
@@ -23,8 +22,7 @@ discard block |
||
23 | 22 | * |
24 | 23 | * @return array|false |
25 | 24 | */ |
26 | - public function findPostByPath($path) |
|
27 | - { |
|
25 | + public function findPostByPath($path) { |
|
28 | 26 | $query = " |
29 | 27 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
30 | 28 | FROM `jpemeric_blog`.`post` |
@@ -41,8 +39,7 @@ discard block |
||
41 | 39 | ->fetchOne($query, $bindings); |
42 | 40 | } |
43 | 41 | |
44 | - public function getActivePosts($limit = null, $offset = 0) |
|
45 | - { |
|
42 | + public function getActivePosts($limit = null, $offset = 0) { |
|
46 | 43 | $query = " |
47 | 44 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
48 | 45 | FROM `jpemeric_blog`.`post` |
@@ -63,8 +60,7 @@ discard block |
||
63 | 60 | ->fetchAll($query, $bindings); |
64 | 61 | } |
65 | 62 | |
66 | - public function getActivePostsCount() |
|
67 | - { |
|
63 | + public function getActivePostsCount() { |
|
68 | 64 | $query = " |
69 | 65 | SELECT COUNT(1) AS `count` |
70 | 66 | FROM `jpemeric_blog`.`post` |
@@ -79,8 +75,7 @@ discard block |
||
79 | 75 | ->fetchValue($query, $bindings); |
80 | 76 | } |
81 | 77 | |
82 | - public function getActivePostsByTag($tag, $limit = null, $offset = 0) |
|
83 | - { |
|
78 | + public function getActivePostsByTag($tag, $limit = null, $offset = 0) { |
|
84 | 79 | $query = " |
85 | 80 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
86 | 81 | FROM `jpemeric_blog`.`post` |
@@ -104,8 +99,7 @@ discard block |
||
104 | 99 | ->fetchAll($query, $bindings); |
105 | 100 | } |
106 | 101 | |
107 | - public function getActivePostsCountByTag($tag) |
|
108 | - { |
|
102 | + public function getActivePostsCountByTag($tag) { |
|
109 | 103 | $query = " |
110 | 104 | SELECT COUNT(1) AS `count` |
111 | 105 | FROM `jpemeric_blog`.`post` |
@@ -123,8 +117,7 @@ discard block |
||
123 | 117 | ->fetchValue($query, $bindings); |
124 | 118 | } |
125 | 119 | |
126 | - public function getActivePostsByCategory($category, $limit = null, $offset = 0) |
|
127 | - { |
|
120 | + public function getActivePostsByCategory($category, $limit = null, $offset = 0) { |
|
128 | 121 | $query = " |
129 | 122 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
130 | 123 | FROM `jpemeric_blog`.`post` |
@@ -146,8 +139,7 @@ discard block |
||
146 | 139 | ->fetchAll($query, $bindings); |
147 | 140 | } |
148 | 141 | |
149 | - public function getActivePostsCountByCategory($category) |
|
150 | - { |
|
142 | + public function getActivePostsCountByCategory($category) { |
|
151 | 143 | $query = " |
152 | 144 | SELECT COUNT(1) AS `count` |
153 | 145 | FROM `jpemeric_blog`.`post` |
@@ -163,8 +155,7 @@ discard block |
||
163 | 155 | ->fetchValue($query, $bindings); |
164 | 156 | } |
165 | 157 | |
166 | - public function getActivePostsByRelatedTags($post, $limit = 4) |
|
167 | - { |
|
158 | + public function getActivePostsByRelatedTags($post, $limit = 4) { |
|
168 | 159 | $query = " |
169 | 160 | SELECT `id`, `title`, `path`, `date`, `body`, `category`, COUNT(1) AS `count` |
170 | 161 | FROM `jpemeric_blog`.`post` |