@@ -127,8 +127,9 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function setWhiteList(array $whiteList) |
| 129 | 129 | { |
| 130 | - if (empty($whiteList)) |
|
| 131 | - throw new \RuntimeException("Empty whitelist!"); |
|
| 130 | + if (empty($whiteList)) { |
|
| 131 | + throw new \RuntimeException("Empty whitelist!"); |
|
| 132 | + } |
|
| 132 | 133 | |
| 133 | 134 | $this->whiteList = $whiteList; |
| 134 | 135 | } |
@@ -156,8 +157,9 @@ discard block |
||
| 156 | 157 | { |
| 157 | 158 | foreach ($options as $option => $value) |
| 158 | 159 | { |
| 159 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
| 160 | - $this->{'set'.$option}($value); |
|
| 160 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) { |
|
| 161 | + $this->{'set'.$option}($value); |
|
| 162 | + } |
|
| 161 | 163 | } |
| 162 | 164 | |
| 163 | 165 | # HTTP instance |
@@ -64,11 +64,13 @@ |
||
| 64 | 64 | */ |
| 65 | 65 | public static function getClientIP() |
| 66 | 66 | { |
| 67 | - if (!empty($_SERVER['HTTP_CLIENT_IP'])) |
|
| 68 | - return $_SERVER['HTTP_CLIENT_IP']; |
|
| 67 | + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 68 | + return $_SERVER['HTTP_CLIENT_IP']; |
|
| 69 | + } |
|
| 69 | 70 | |
| 70 | - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) |
|
| 71 | - return $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 71 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 72 | + return $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 73 | + } |
|
| 72 | 74 | |
| 73 | 75 | return $_SERVER['REMOTE_ADDR']; |
| 74 | 76 | } |
@@ -131,7 +131,7 @@ |
||
| 131 | 131 | if (\PEAR::isError($mail)) |
| 132 | 132 | { |
| 133 | 133 | $this->error( |
| 134 | - $mail->getCode(), $mail->getMessage() |
|
| 134 | + $mail->getCode(), $mail->getMessage() |
|
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | 137 | return false; |
@@ -74,18 +74,21 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | @include_once 'System.php'; |
| 76 | 76 | |
| 77 | - if (!class_exists('System', false)) |
|
| 78 | - throw new \RuntimeException("PEAR is not installed in your system!"); |
|
| 77 | + if (!class_exists('System', false)) { |
|
| 78 | + throw new \RuntimeException("PEAR is not installed in your system!"); |
|
| 79 | + } |
|
| 79 | 80 | |
| 80 | 81 | include_once 'Net/SMTP.php'; |
| 81 | 82 | |
| 82 | - if (!class_exists('\Net_SMTP', false)) |
|
| 83 | - throw new \RuntimeException("PEAR::Net_SMTP is not installed!"); |
|
| 83 | + if (!class_exists('\Net_SMTP', false)) { |
|
| 84 | + throw new \RuntimeException("PEAR::Net_SMTP is not installed!"); |
|
| 85 | + } |
|
| 84 | 86 | |
| 85 | 87 | @include_once 'Mail.php'; |
| 86 | 88 | |
| 87 | - if (!class_exists('\Mail', false)) |
|
| 88 | - throw new \RuntimeException("PEAR::Mail is not installed!"); |
|
| 89 | + if (!class_exists('\Mail', false)) { |
|
| 90 | + throw new \RuntimeException("PEAR::Mail is not installed!"); |
|
| 91 | + } |
|
| 89 | 92 | } |
| 90 | 93 | |
| 91 | 94 | /** |
@@ -98,8 +101,9 @@ discard block |
||
| 98 | 101 | */ |
| 99 | 102 | protected function error($code, $message = null) |
| 100 | 103 | { |
| 101 | - if (!array_key_exists($code, $this->errors)) |
|
| 102 | - $this->errors[$message] = (is_null($message) && array_key_exists($code, $this->errors)) ? $this->errors[$code] : $message; |
|
| 104 | + if (!array_key_exists($code, $this->errors)) { |
|
| 105 | + $this->errors[$message] = (is_null($message) && array_key_exists($code, $this->errors)) ? $this->errors[$code] : $message; |
|
| 106 | + } |
|
| 103 | 107 | } |
| 104 | 108 | |
| 105 | 109 | /** |
@@ -70,8 +70,9 @@ |
||
| 70 | 70 | { |
| 71 | 71 | $parameters = $this->getParams(); |
| 72 | 72 | |
| 73 | - if (array_key_exists($param, $parameters)) |
|
| 74 | - return true; |
|
| 73 | + if (array_key_exists($param, $parameters)) { |
|
| 74 | + return true; |
|
| 75 | + } |
|
| 75 | 76 | |
| 76 | 77 | return false; |
| 77 | 78 | } |
@@ -77,8 +77,9 @@ |
||
| 77 | 77 | |
| 78 | 78 | foreach ($arguments as $key => $arg) |
| 79 | 79 | { |
| 80 | - if (is_string($arg)) |
|
| 81 | - $arguments[$key] = "'$arg'"; |
|
| 80 | + if (is_string($arg)) { |
|
| 81 | + $arguments[$key] = "'$arg'"; |
|
| 82 | + } |
|
| 82 | 83 | } |
| 83 | 84 | |
| 84 | 85 | $arguments = implode(", ", array_values($arguments)); |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @param array $where |
| 24 | 24 | */ |
| 25 | - public function select(Array $where); |
|
| 25 | + public function select(Array $where); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Insert statement |
| 29 | 29 | * |
| 30 | 30 | * @param array $data |
| 31 | 31 | */ |
| 32 | - public function insert(Array $data); |
|
| 32 | + public function insert(Array $data); |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Update statement |
@@ -37,12 +37,12 @@ discard block |
||
| 37 | 37 | * @param array $set |
| 38 | 38 | * @param array $where |
| 39 | 39 | */ |
| 40 | - public function update(Array $set, Array $where); |
|
| 40 | + public function update(Array $set, Array $where); |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Delete statement |
| 44 | 44 | * |
| 45 | 45 | * @param array $where |
| 46 | 46 | */ |
| 47 | - public function delete(Array $where); |
|
| 47 | + public function delete(Array $where); |
|
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |
@@ -58,8 +58,9 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $result = $this->tableGateway->select($where); |
| 60 | 60 | |
| 61 | - if (!count($result)) |
|
| 62 | - return $result; |
|
| 61 | + if (!count($result)) { |
|
| 62 | + return $result; |
|
| 63 | + } |
|
| 63 | 64 | |
| 64 | 65 | $array_result = []; |
| 65 | 66 | |
@@ -69,8 +70,9 @@ discard block |
||
| 69 | 70 | |
| 70 | 71 | foreach ($row as $key => $value) |
| 71 | 72 | { |
| 72 | - if (is_string($key)) |
|
| 73 | - $filtered_array[$key] = $value; |
|
| 73 | + if (is_string($key)) { |
|
| 74 | + $filtered_array[$key] = $value; |
|
| 75 | + } |
|
| 74 | 76 | } |
| 75 | 77 | |
| 76 | 78 | $user_entity = get_class($this->tableGateway->getEntity()); |
@@ -94,10 +96,11 @@ discard block |
||
| 94 | 96 | */ |
| 95 | 97 | public function insert($entity) |
| 96 | 98 | { |
| 97 | - if ($entity instanceof Entity) |
|
| 98 | - $entity = get_object_vars($entity); |
|
| 99 | - else if (!is_array($entity)) |
|
| 100 | - throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
| 99 | + if ($entity instanceof Entity) { |
|
| 100 | + $entity = get_object_vars($entity); |
|
| 101 | + } else if (!is_array($entity)) { |
|
| 102 | + throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
| 103 | + } |
|
| 101 | 104 | |
| 102 | 105 | $this->parseEntity($entity); |
| 103 | 106 | |
@@ -126,14 +129,15 @@ discard block |
||
| 126 | 129 | |
| 127 | 130 | foreach ($entity as $key => $value) |
| 128 | 131 | { |
| 129 | - if (in_array($key, $changedFields)) |
|
| 130 | - $fieldsToModify[$key] = $value; |
|
| 132 | + if (in_array($key, $changedFields)) { |
|
| 133 | + $fieldsToModify[$key] = $value; |
|
| 134 | + } |
|
| 131 | 135 | } |
| 132 | 136 | |
| 133 | 137 | $entity = $fieldsToModify; |
| 138 | + } else if (!is_array($entity)) { |
|
| 139 | + throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
| 134 | 140 | } |
| 135 | - else if (!is_array($entity)) |
|
| 136 | - throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
| 137 | 141 | |
| 138 | 142 | $this->parseEntity($entity); |
| 139 | 143 | |
@@ -152,10 +156,11 @@ discard block |
||
| 152 | 156 | */ |
| 153 | 157 | public function delete($entity) |
| 154 | 158 | { |
| 155 | - if ($entity instanceof Entity) |
|
| 156 | - $entity = get_object_vars($entity); |
|
| 157 | - else if (!is_array($entity)) |
|
| 158 | - throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
| 159 | + if ($entity instanceof Entity) { |
|
| 160 | + $entity = get_object_vars($entity); |
|
| 161 | + } else if (!is_array($entity)) { |
|
| 162 | + throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
| 163 | + } |
|
| 159 | 164 | |
| 160 | 165 | return $this->tableGateway->delete($entity); |
| 161 | 166 | } |
@@ -108,8 +108,9 @@ |
||
| 108 | 108 | { |
| 109 | 109 | foreach ($options as $option => $value) |
| 110 | 110 | { |
| 111 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
| 112 | - $this->{'set'.$option}($value); |
|
| 111 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) { |
|
| 112 | + $this->{'set'.$option}($value); |
|
| 113 | + } |
|
| 113 | 114 | } |
| 114 | 115 | |
| 115 | 116 | if (!($socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) |
@@ -107,11 +107,12 @@ |
||
| 107 | 107 | { |
| 108 | 108 | $this->$prop = $value; |
| 109 | 109 | |
| 110 | - if (!in_array($prop, $this->changedFields)) |
|
| 111 | - $this->changedFields[] = $prop; |
|
| 110 | + if (!in_array($prop, $this->changedFields)) { |
|
| 111 | + $this->changedFields[] = $prop; |
|
| 112 | + } |
|
| 113 | + } else { |
|
| 114 | + throw new \LogicException("The property '$prop' does not exists in the class ' " . get_class($this) . " '"); |
|
| 112 | 115 | } |
| 113 | - else |
|
| 114 | - throw new \LogicException("The property '$prop' does not exists in the class ' " . get_class($this) . " '"); |
|
| 115 | 116 | } |
| 116 | 117 | } |
| 117 | 118 | |