Passed
Push — master ( 802056...afdc54 )
by Tomasz
05:56
created
web/lib/admin/view/html/Button.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@
 block discarded – undo
6 6
  * @author Zilvinas Vaira
7 7
  *
8 8
  */
9
-class Button extends Tag{
9
+class Button extends Tag {
10 10
     
11 11
     const SUBMIT_TYPE = 'submit';
12 12
     const RESET_TYPE = 'reset';
13 13
     const BUTTON_TYPE = 'button';
14 14
     
15
-    public function __construct($title, $type = self::SUBMIT_TYPE, $name = '', $value = '', $class = '', $id = ''){
15
+    public function __construct($title, $type = self::SUBMIT_TYPE, $name = '', $value = '', $class = '', $id = '') {
16 16
         parent::__construct('button');
17 17
         $this->addAttribute('type', $type);
18 18
         $this->addAttribute('name', $name);
Please login to merge, or discard this patch.
web/lib/admin/view/html/CompositeTag.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      * 
22 22
      * @return UnaryTag[]
23 23
      */
24
-    public function getTags(){
24
+    public function getTags() {
25 25
         return $this->tags;
26 26
     }
27 27
     
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * 
30 30
      * @return number
31 31
      */
32
-    public function size(){
32
+    public function size() {
33 33
         return count($this->tags);
34 34
     }
35 35
     
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
      * {@inheritDoc}
39 39
      * @see \lib\html\Tag::composeInnerString()
40 40
      */
41
-    protected function composeInnerString(){
41
+    protected function composeInnerString() {
42 42
         $innerString = "\n\t" . $this->tab . $this->text;
43 43
         foreach ($this->tags as $tag) {
44
-            $tag->setTab("\t".$this->tab);
44
+            $tag->setTab("\t" . $this->tab);
45 45
             $innerString .= $tag;
46 46
         }
47 47
         return $innerString;
Please login to merge, or discard this patch.
web/lib/admin/view/TitledFormDecorator.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 
4 4
 use web\lib\admin\view\html\Attribute;
5 5
 
6
-class TitledFormDecorator extends PageElementDecorator{
6
+class TitledFormDecorator extends PageElementDecorator {
7 7
     
8 8
     const BEFORE = 0;
9 9
     
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * 
35 35
      * @var array
36 36
      */
37
-    private $elements = array( self::BEFORE => array(), self::AFTER => array());
37
+    private $elements = array(self::BEFORE => array(), self::AFTER => array());
38 38
     
39 39
     /**
40 40
      * 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      * @param string $class
43 43
      * @param string $title
44 44
      */
45
-    public function __construct($element, $title, $action, $class = '', $method = 'post', $charset = 'UTF-8'){
45
+    public function __construct($element, $title, $action, $class = '', $method = 'post', $charset = 'UTF-8') {
46 46
         parent::__construct($element, $class);
47 47
         $this->title = $title;
48 48
         $this->action = new Attribute('action', $action);
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
         $this->charset = new Attribute('accept-charset', $charset);
51 51
     }
52 52
     
53
-    public function addHtmlElement($element, $position = self::AFTER){
53
+    public function addHtmlElement($element, $position = self::AFTER) {
54 54
         $this->elements[$position][] = $element;
55 55
     }
56 56
     
57 57
     public function render() {
58 58
         ?>
59
-        <form enctype="multipart/form-data"<?php echo $this->action.$this->method.$this->charset; ?>>
59
+        <form enctype="multipart/form-data"<?php echo $this->action . $this->method . $this->charset; ?>>
60 60
             <fieldset<?php echo $this->class; ?>>
61 61
                 <legend>
62 62
                     <strong><?php echo $this->title; ?></strong>
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
                 <?php
66 66
                     foreach ($this->elements[self::BEFORE] as $element) {
67
-                        echo "\n".$element;
67
+                        echo "\n" . $element;
68 68
                     }
69 69
                 ?>
70 70
 
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
                     $this->element->render();
73 73
                 ?>
74 74
 
75
-                <?php if(count($this->elements[self::AFTER]) > 0){ ?>
75
+                <?php if (count($this->elements[self::AFTER]) > 0) { ?>
76 76
                 <div style="padding: 20px;">
77 77
                 <?php
78 78
                     foreach ($this->elements[self::AFTER] as $element) {
79
-                        echo "\n".$element;
79
+                        echo "\n" . $element;
80 80
                     }
81 81
                 ?>
82 82
                 </div>
Please login to merge, or discard this patch.
web/lib/admin/view/DatePicker.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
      * @param string $name Name of an input element
46 46
      * @param string $format Defines a format template for the date value
47 47
      */
48
-    public function __construct($name, $format='yyyy-MM-dd'){
48
+    public function __construct($name, $format = 'yyyy-MM-dd') {
49 49
         self::$COUNT++;
50
-        $this->id = self::INPUT_CLASS.'-'.self::$COUNT;
50
+        $this->id = self::INPUT_CLASS . '-' . self::$COUNT;
51 51
         $this->name = $name;
52 52
         $this->format = $format;
53 53
     }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * {@inheritDoc}
58 58
      * @see \web\lib\admin\view\PageElementInterface::render()
59 59
      */
60
-    public function render(){
60
+    public function render() {
61 61
         echo $this;
62 62
         
63 63
         /*?>
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         */
70 70
     }
71 71
     
72
-    public function __toString(){
72
+    public function __toString() {
73 73
         $div = new CompositeTag('div');
74 74
         $div->addAttribute('class', self::BLOCK_CLASS);
75 75
             $input = new UnaryTag('input');
Please login to merge, or discard this patch.
web/lib/admin/view/InfoBlockTable.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use web\lib\admin\view\html\Table;
5 5
 use web\lib\admin\view\html\Row;
6 6
 
7
-class InfoBlockTable implements PageElementInterface{
7
+class InfoBlockTable implements PageElementInterface {
8 8
     
9 9
     /**
10 10
      * 
@@ -18,22 +18,22 @@  discard block
 block discarded – undo
18 18
      */
19 19
     private $decorator;
20 20
     
21
-    public function __construct($title){
21
+    public function __construct($title) {
22 22
         $this->table = new Table();
23 23
         $this->table->addAttribute("cellpadding", 5);
24
-        $this->decorator = new TitledBlockDecorator($this->table, $title,  PageElementInterface::INFOBLOCK_CLASS);
24
+        $this->decorator = new TitledBlockDecorator($this->table, $title, PageElementInterface::INFOBLOCK_CLASS);
25 25
     }
26 26
     
27 27
     /**
28 28
      * @param array $rowArray
29 29
      */
30
-    public function addRow($rowArray){
30
+    public function addRow($rowArray) {
31 31
         $row = new Row($rowArray);
32 32
         $row->addCellAttribute(0, 'class', Table::TITLED_CELL_CLASS);
33 33
         $this->table->addRow($row);
34 34
     }
35 35
     
36
-    public function render(){
36
+    public function render() {
37 37
         $this->decorator->render();
38 38
     }
39 39
 }
Please login to merge, or discard this patch.
web/lib/admin/view/TitledBlockDecorator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace web\lib\admin\view;
3 3
 
4
-class TitledBlockDecorator extends PageElementDecorator{
4
+class TitledBlockDecorator extends PageElementDecorator {
5 5
     
6 6
     /**
7 7
      * 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
      * @param string $class
16 16
      * @param string $title
17 17
      */
18
-    public function __construct($element, $title, $class = ""){
18
+    public function __construct($element, $title, $class = "") {
19 19
         parent::__construct($element, $class);
20 20
         $this->title = $title;
21 21
         
Please login to merge, or discard this patch.
web/lib/admin/view/PageElementDecorator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 
4 4
 use web\lib\admin\view\html\Attribute;
5 5
 
6
-abstract class PageElementDecorator implements PageElementInterface{
6
+abstract class PageElementDecorator implements PageElementInterface {
7 7
     
8 8
     /**
9 9
      * 
Please login to merge, or discard this patch.
web/lib/admin/domain/PersistentEntity.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      * @param string $table
57 57
      * @param string $databaseType
58 58
      */
59
-    public function __construct($table, $databaseType = 'INST'){
59
+    public function __construct($table, $databaseType = 'INST') {
60 60
         $this->table = $table;
61 61
         $this->setAttributeType(self::ID, Attribute::TYPE_INTEGER);
62 62
         $this->databaseHandle = \core\DBConnection::handle($databaseType);
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      * @param string $key
68 68
      * @param string $type
69 69
      */
70
-    protected function setAttributeType($key, $type){
70
+    protected function setAttributeType($key, $type) {
71 71
         $this->types[$key] = $type; 
72 72
     }
73 73
     
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      * @param string $key
77 77
      * @return string
78 78
      */
79
-    protected function getAttributeType($key){
79
+    protected function getAttributeType($key) {
80 80
         return isset($this->types[$key]) ? $this->types[$key] : Attribute::TYPE_STRING;
81 81
     }
82 82
     
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      * @param string $key
87 87
      * @return string
88 88
      */
89
-    public function get($key){
89
+    public function get($key) {
90 90
         return isset($this->row[$key]) ? $this->row[$key]->value : "";
91 91
     }
92 92
     
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      * @param string $key
96 96
      * @return NULL|\web\lib\admin\domain\Attribute
97 97
      */
98
-    public function getAttribute($key){
98
+    public function getAttribute($key) {
99 99
         return isset($this->row[$key]) ? $this->row[$key] : new Attribute('', '');
100 100
     }
101 101
     
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      * @param string $key
106 106
      * @param mixed $value
107 107
      */
108
-    protected function set($key, $value){
108
+    protected function set($key, $value) {
109 109
         $attribute = new Attribute($key, $value, $this->getAttributeType($key));
110 110
         $this->row[$key] = $attribute;
111 111
     }
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
      * 
115 115
      * @param array $row
116 116
      */
117
-    public function setRow($row){
117
+    public function setRow($row) {
118 118
         $this->clear();
119
-        foreach ($row as $key => $value){
119
+        foreach ($row as $key => $value) {
120 120
             $this->set($key, $value);
121 121
         }
122 122
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     /**
125 125
      * 
126 126
      */
127
-    public function clear(){
127
+    public function clear() {
128 128
         $this->row = array();
129 129
     }
130 130
     
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      * 
133 133
      * @return string
134 134
      */
135
-    public function getIdentifier(){
135
+    public function getIdentifier() {
136 136
         return $this->get(self::ID);
137 137
     }
138 138
     
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
141 141
      * {@inheritDoc}
142 142
      * @see \web\lib\admin\domain\PersistentInterface::save()
143 143
      */
144
-    public function save(){
144
+    public function save() {
145 145
         $result = false;
146
-        if(count($this->row) > 0){
147
-            if(isset($this->row[self::ID])){
146
+        if (count($this->row) > 0) {
147
+            if (isset($this->row[self::ID])) {
148 148
                 $result = $this->executeUpdateQuery();
149
-            }else{
149
+            } else {
150 150
                 $result = $this->executeInsertQuery();
151 151
             }
152 152
         }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      * 
158 158
      * @return boolean|mixed
159 159
      */
160
-    private function executeInsertQuery(){
160
+    private function executeInsertQuery() {
161 161
         $result = false;
162 162
         $query = sprintf("INSERT INTO `%s`", $this->table);
163 163
         $keyString = "(";
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
         $types = '';
166 166
         $arguments = array();
167 167
         foreach ($this->row as $key => $attribute) {
168
-            if($keyString != "(") $keyString .= " ,";
169
-            if($valueString != "(") $valueString .= " ,";
168
+            if ($keyString != "(") $keyString .= " ,";
169
+            if ($valueString != "(") $valueString .= " ,";
170 170
             $keyString .= "`" . $key . "`";
171 171
             $valueString .= "?";
172 172
             $types .= $attribute->getType();
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
         }
175 175
         $keyString .= ")";
176 176
         $valueString .= ")";
177
-        if($keyString != "()"){
178
-            $query .= " " .$keyString . " VALUES " . $valueString;
177
+        if ($keyString != "()") {
178
+            $query .= " " . $keyString . " VALUES " . $valueString;
179 179
             $result = $this->databaseHandle->exec($query, $types, ...$arguments);
180
-            if($result){
180
+            if ($result) {
181 181
                 $this->set(self::ID, $this->databaseHandle->lastID());
182 182
             }
183 183
         }
@@ -188,21 +188,21 @@  discard block
 block discarded – undo
188 188
      * 
189 189
      * @return boolean|mixed
190 190
      */
191
-    private function executeUpdateQuery(){
191
+    private function executeUpdateQuery() {
192 192
         $result = false;
193 193
         $query = sprintf("UPDATE `%s`", $this->table);
194 194
         $updateString = "";
195 195
         $types = '';
196 196
         $arguments = array();
197 197
         foreach ($this->row as $key => $attribute) {
198
-            if(!empty($updateString)) $updateString .= " ,";
199
-            else $updateString .=" SET ";
198
+            if (!empty($updateString)) $updateString .= " ,";
199
+            else $updateString .= " SET ";
200 200
             $updateString .= "`" . $key . "`=?";
201 201
             $types .= $attribute->getType();
202 202
             $arguments [] = $attribute->value;
203 203
         }
204
-        if(!empty($updateString)){
205
-            $query .= " " .$updateString . " WHERE `" .self::ID. "`=?";
204
+        if (!empty($updateString)) {
205
+            $query .= " " . $updateString . " WHERE `" . self::ID . "`=?";
206 206
             $id = $this->getAttribute(self::ID);
207 207
             $types .= $id->getType();
208 208
             $arguments [] = $id->value;
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
      * {@inheritDoc}
216 216
      * @see \web\lib\admin\domain\PersistentInterface::load()
217 217
      */
218
-    public function load($searchAttribute = null){
218
+    public function load($searchAttribute = null) {
219 219
         $state = false;
220 220
         $id = $this->getAttribute(self::ID);
221 221
         $query = sprintf("SELECT * FROM `%s` WHERE `%s` =?", $this->table, self::ID);
222 222
         $result = $this->databaseHandle->exec($query, $id->getType(), $id->value);
223
-        if(mysqli_num_rows($result)>0){
223
+        if (mysqli_num_rows($result) > 0) {
224 224
             $this->setRow(mysqli_fetch_assoc($result));
225 225
             $state = true;
226 226
         }
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      * {@inheritDoc}
233 233
      * @see \web\lib\admin\domain\PersistentInterface::delete()
234 234
      */
235
-    public function delete(){
235
+    public function delete() {
236 236
         $id = $this->getAttribute(self::ID);
237 237
         $query = sprintf("DELETE FROM `%s` WHERE `%s`=?", $this->table, self::ID);
238 238
         return $this->databaseHandle->exec($query, $id->getType(), $id->value);
Please login to merge, or discard this patch.
web/lib/admin/view/html/Row.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @author Zilvinas Vaira
7 7
  *
8 8
  */
9
-class Row extends Tag{
9
+class Row extends Tag {
10 10
     
11 11
     /**
12 12
      * 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      * 
42 42
      * @param array $cells
43 43
      */
44
-    public function setCells($cells){
44
+    public function setCells($cells) {
45 45
         foreach ($cells as $key => $cell) {
46 46
             $td = new CompositeTag('td');
47 47
             $td->addText($cell);
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * 
54 54
      * @return number
55 55
      */
56
-    public function size(){
56
+    public function size() {
57 57
         return count($this->cells);
58 58
     }
59 59
     
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * 
62 62
      * @return \web\lib\admin\view\html\CompositeTag[]
63 63
      */
64
-    public function getCells(){
64
+    public function getCells() {
65 65
         return $this->cells;
66 66
     }
67 67
     
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
      * @param string $name
72 72
      * @param string $value
73 73
      */
74
-    public function addCellAttribute($column, $name, $value){
75
-        if(isset($this->cells[$column])){
74
+    public function addCellAttribute($column, $name, $value) {
75
+        if (isset($this->cells[$column])) {
76 76
             $this->cells[$column]->addAttribute($name, $value);
77 77
         }
78 78
     }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      * 
82 82
      * @param array $columns
83 83
      */
84
-    public function setColumns($columns){
84
+    public function setColumns($columns) {
85 85
         $this->columns = $columns;
86 86
     }
87 87
     
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
      * @param string $column
91 91
      * @param UnaryTag $element
92 92
      */
93
-    public function addToCell($column, $element){
94
-        if(!isset($this->cells[$column])){
93
+    public function addToCell($column, $element) {
94
+        if (!isset($this->cells[$column])) {
95 95
             $this->cells[$column] = new CompositeTag('td');
96 96
         }
97 97
         $this->cells[$column]->addTag($element);
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
      * @param string $column
103 103
      * @return \web\lib\admin\view\html\CompositeTag
104 104
      */
105
-    public function getCell($column){
106
-        if(!isset($this->cells[$column])){
105
+    public function getCell($column) {
106
+        if (!isset($this->cells[$column])) {
107 107
             $this->cells[$column] = new CompositeTag('td');
108 108
         }
109 109
         return $this->cells[$column];
@@ -114,19 +114,19 @@  discard block
 block discarded – undo
114 114
      * {@inheritDoc}
115 115
      * @see \web\lib\admin\view\html\Tag::composeInnerString()
116 116
      */
117
-    public function composeInnerString(){
118
-        if(count($this->columns)>0){
117
+    public function composeInnerString() {
118
+        if (count($this->columns) > 0) {
119 119
             $innerString = "";
120 120
             foreach ($this->columns as $column) {
121
-                if(!isset($this->cells[$column])){
121
+                if (!isset($this->cells[$column])) {
122 122
                     $this->cells[$column] = new CompositeTag('td');
123 123
                 }
124
-                $this->cells[$column]->setTab("\t".$this->tab);
124
+                $this->cells[$column]->setTab("\t" . $this->tab);
125 125
                 $innerString .= $this->cells[$column];
126 126
                 
127 127
             }
128 128
             return $innerString;
129
-        }else{
129
+        } else {
130 130
             return parent::composeInnerString();
131 131
         }
132 132
     }
Please login to merge, or discard this patch.