@@ -37,8 +37,7 @@ discard block |
||
37 | 37 | public static function prepare($setOrCheck = false) |
38 | 38 | { |
39 | 39 | //@see http://php.net/manual/es/function.filter-input.php#77307 |
40 | - $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?: |
|
41 | - filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL); |
|
40 | + $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?: filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL); |
|
42 | 41 | |
43 | 42 | $extension = pathinfo(strtok($uri, '?'), PATHINFO_EXTENSION); |
44 | 43 | |
@@ -70,9 +69,9 @@ discard block |
||
70 | 69 | self::$t['order']['col'] = $orderBy; |
71 | 70 | $dir = strtolower($orderDir); |
72 | 71 | self::$t['order']['dir'] = in_array($dir, ['asc', 'desc']) ? |
73 | - $dir : self::error('Invalid orderDir (Asc/Desc): '.$orderDir); |
|
72 | + $dir : self::error('Invalid orderDir (Asc/Desc): ' . $orderDir); |
|
74 | 73 | self::$t['paging'] = ($num = abs($paging)) >= 10 ? |
75 | - $num : self::error('Invalid paging (<10): '.$paging); |
|
74 | + $num : self::error('Invalid paging (<10): ' . $paging); |
|
76 | 75 | } |
77 | 76 | |
78 | 77 | /** |
@@ -89,7 +88,7 @@ discard block |
||
89 | 88 | self::$t = self::request(self::$export); |
90 | 89 | |
91 | 90 | $order = [self::$t['order']['col'] => self::$t['order']['dir']]; |
92 | - $offset = (self::$t['page'] - 1) * self::$t['paging']; |
|
91 | + $offset = (self::$t['page'] - 1)*self::$t['paging']; |
|
93 | 92 | $limit = [$offset, self::$t['paging']]; |
94 | 93 | self::$t['q'] = self::query($query, self::$t['filter'], $order, $limit, true); |
95 | 94 | |
@@ -102,7 +101,7 @@ discard block |
||
102 | 101 | try { |
103 | 102 | self::$data = self::select($q); |
104 | 103 | } catch (Exception $e) { |
105 | - self::error('ERROR: '.$q.'<br />'.$e->getMessage()); |
|
104 | + self::error('ERROR: ' . $q . '<br />' . $e->getMessage()); |
|
106 | 105 | } |
107 | 106 | } |
108 | 107 | |
@@ -114,7 +113,7 @@ discard block |
||
114 | 113 | echo parent::load(); |
115 | 114 | } else { |
116 | 115 | $tableId = filter_input(INPUT_GET, 'table-id') ?: null; |
117 | - if ($tableId === self::$t['items'].'-table') { |
|
116 | + if ($tableId === self::$t['items'] . '-table') { |
|
118 | 117 | ob_get_clean(); |
119 | 118 | ob_start('ob_gzhandler'); |
120 | 119 | if (!self::$export) { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @covers Table::prepare |
31 | 31 | * @covers Table::confirmValue |
32 | 32 | */ |
33 | - public function testprepare(){ |
|
33 | + public function testprepare() { |
|
34 | 34 | $_SERVER['REQUEST_URI'] = 'test.json'; |
35 | 35 | |
36 | 36 | //Table::prepare(true); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @covers Table::error |
53 | 53 | * @covers Table::config |
54 | 54 | */ |
55 | - public function testcreate(){ |
|
55 | + public function testcreate() { |
|
56 | 56 | $_SERVER['REQUEST_URI'] = 'test/users'; |
57 | 57 | |
58 | 58 | Table::prepare(); |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | Table::create($items, $orderBy, 'a'); |
67 | 67 | $this->assertSame(Table::confirmValue('t.items', $items), true); |
68 | 68 | $this->assertSame(Table::confirmValue('t.order.col', $orderBy), true); |
69 | - $err = Table::confirmValue('errors.0','Invalid orderDir (Asc/Desc): a'); |
|
70 | - $this->assertSame($err,true); |
|
69 | + $err = Table::confirmValue('errors.0', 'Invalid orderDir (Asc/Desc): a'); |
|
70 | + $this->assertSame($err, true); |
|
71 | 71 | |
72 | 72 | Table::create($items, $orderBy, 'asc', 2); |
73 | 73 | $this->assertSame(Table::confirmValue('t.items', $items), true); |
74 | 74 | $this->assertSame(Table::confirmValue('t.order.col', $orderBy), true); |
75 | 75 | $this->assertSame(Table::confirmValue('t.order.dir', 'asc'), true); |
76 | - $err1 = Table::confirmValue('errors.∞','Invalid paging (<10): 2'); |
|
76 | + $err1 = Table::confirmValue('errors.∞', 'Invalid paging (<10): 2'); |
|
77 | 77 | $this->assertSame($err1, true); |
78 | 78 | } |
79 | 79 | |
@@ -130,17 +130,17 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | |
133 | - static function prepare($classMethod, $setOrCheck = false){ |
|
134 | - self::$pageExtension = pathinfo($_SERVER['REQUEST_URI'], PATHINFO_EXTENSION)?:null; |
|
133 | + static function prepare($classMethod, $setOrCheck = false) { |
|
134 | + self::$pageExtension = pathinfo($_SERVER['REQUEST_URI'], PATHINFO_EXTENSION) ?: null; |
|
135 | 135 | $continuePreparation = $setOrCheck === false; |
136 | - if($setOrCheck === true){ |
|
137 | - if(!in_array($classMethod, self::$preparePassed) && empty(self::$pageExtension)){ |
|
138 | - die("ERROR (in a ".__CLASS__." call): Please call the ".$classMethod."(); method before the page headers sent."); |
|
136 | + if ($setOrCheck === true) { |
|
137 | + if (!in_array($classMethod, self::$preparePassed) && empty(self::$pageExtension)) { |
|
138 | + die("ERROR (in a " . __CLASS__ . " call): Please call the " . $classMethod . "(); method before the page headers sent."); |
|
139 | 139 | } |
140 | - } else if(!empty($setOrCheck)) { |
|
140 | + } else if (!empty($setOrCheck)) { |
|
141 | 141 | self::$pageExtension = $setOrCheck; |
142 | 142 | } |
143 | - if(!in_array($classMethod, self::$preparePassed)){ |
|
143 | + if (!in_array($classMethod, self::$preparePassed)) { |
|
144 | 144 | self::$preparePassed[] = $classMethod; |
145 | 145 | } |
146 | 146 | return $continuePreparation; |
@@ -30,7 +30,8 @@ discard block |
||
30 | 30 | * @covers Table::prepare |
31 | 31 | * @covers Table::confirmValue |
32 | 32 | */ |
33 | - public function testprepare(){ |
|
33 | + public function testprepare() |
|
34 | + { |
|
34 | 35 | $_SERVER['REQUEST_URI'] = 'test.json'; |
35 | 36 | |
36 | 37 | //Table::prepare(true); |
@@ -52,7 +53,8 @@ discard block |
||
52 | 53 | * @covers Table::error |
53 | 54 | * @covers Table::config |
54 | 55 | */ |
55 | - public function testcreate(){ |
|
56 | + public function testcreate() |
|
57 | + { |
|
56 | 58 | $_SERVER['REQUEST_URI'] = 'test/users'; |
57 | 59 | |
58 | 60 | Table::prepare(); |
@@ -130,7 +132,8 @@ discard block |
||
130 | 132 | } |
131 | 133 | |
132 | 134 | |
133 | - static function prepare($classMethod, $setOrCheck = false){ |
|
135 | + static function prepare($classMethod, $setOrCheck = false) |
|
136 | + { |
|
134 | 137 | self::$pageExtension = pathinfo($_SERVER['REQUEST_URI'], PATHINFO_EXTENSION)?:null; |
135 | 138 | $continuePreparation = $setOrCheck === false; |
136 | 139 | if($setOrCheck === true){ |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | -require_once __DIR__.'/../vendor/autoload.php'; |
|
2 | +require_once __DIR__ . '/../vendor/autoload.php'; |
|
3 | 3 | |
4 | 4 | spl_autoload_register(function($class) { |
5 | - if($class !== 'PHPUnit_Framework_TestSuite.php') { |
|
6 | - include dirname(__DIR__).'/'.$class.'.php'; |
|
5 | + if ($class !== 'PHPUnit_Framework_TestSuite.php') { |
|
6 | + include dirname(__DIR__) . '/' . $class . '.php'; |
|
7 | 7 | } |
8 | 8 | }); |
9 | 9 |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once __DIR__.'/../vendor/autoload.php'; |
3 | 3 | |
4 | -spl_autoload_register(function($class) { |
|
4 | +spl_autoload_register(function($class) { |
|
5 | 5 | if($class !== 'PHPUnit_Framework_TestSuite.php') { |
6 | 6 | include dirname(__DIR__).'/'.$class.'.php'; |
7 | 7 | } |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | |
18 | 18 | public static function assets($path = "/public/table") |
19 | 19 | { |
20 | - return "<script src=\"{$path}/table_helper.js\" defer></script>\n\t". |
|
21 | - "<script src=\"{$path}/table.js\" defer></script>\n\t". |
|
20 | + return "<script src=\"{$path}/table_helper.js\" defer></script>\n\t" . |
|
21 | + "<script src=\"{$path}/table.js\" defer></script>\n\t" . |
|
22 | 22 | "<link href=\"{$path}/table.css\" rel=\"stylesheet\">\n"; |
23 | 23 | } |
24 | 24 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | if ($value === true || (empty($value) && $value != 0)) { |
33 | 33 | $list[] = $key; |
34 | 34 | } else { |
35 | - $list[] = $key.'="'.$value.'"'; |
|
35 | + $list[] = $key . '="' . $value . '"'; |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | return rtrim(implode(' ', $list)); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | self::$cols = []; |
60 | 60 | self::$t['rows'] = null; |
61 | 61 | } else { |
62 | - echo 'Existing table-id used in table::create(): '.$items; |
|
62 | + echo 'Existing table-id used in table::create(): ' . $items; |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -71,23 +71,22 @@ discard block |
||
71 | 71 | try { |
72 | 72 | $p = explode('.', $property); |
73 | 73 | $name = array_shift($p); |
74 | - if(property_exists(__CLASS__, $name)){ |
|
75 | - switch(sizeof($p)){ |
|
74 | + if (property_exists(__CLASS__, $name)) { |
|
75 | + switch (sizeof($p)) { |
|
76 | 76 | case 3: return static::$$name[$p[0]][$p[1]][$p[2]] === $value; |
77 | 77 | case 2: return static::$$name[$p[0]][$p[1]] === $value; |
78 | 78 | case 1: return $p[0] === '∞' ? //request is to the last one |
79 | - static::$$name[(sizeof(static::$$name)-1)] === $value : |
|
80 | - static::$$name[$p[0]] === $value; |
|
79 | + static::$$name[(sizeof(static::$$name) - 1)] === $value : static::$$name[$p[0]] === $value; |
|
81 | 80 | case 0: return static::$$name === $value; |
82 | 81 | default: |
83 | 82 | $oops = implode($p); |
84 | 83 | throw new Exception('Missing value (' . $oops . ').'); |
85 | 84 | } |
86 | 85 | } else { |
87 | - throw new Exception('Undefined property ('.$name.').'); |
|
86 | + throw new Exception('Undefined property (' . $name . ').'); |
|
88 | 87 | } |
89 | 88 | } catch (Exception $e) { |
90 | - echo 'Caught exception: ', $e->getMessage(), "\n"; |
|
89 | + echo 'Caught exception: ', $e->getMessage(), "\n"; |
|
91 | 90 | } |
92 | 91 | return false; |
93 | 92 | } |