Skip to content

Commit 902eba8

Browse files
authored
Merge pull request #3 from arojunior/scrutinizer-patch-1
Scrutinizer Auto-Fixes
2 parents 542aa5d + a573ecb commit 902eba8

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

core/helper/Helper.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public function toJson($dados, $charset = 'UTF-8')
88
header('Content-Type: application/json');
99

1010
if ($charset <> 'UFT-8') {
11-
array_walk_recursive($dados, function (&$value, $key) {
11+
array_walk_recursive($dados, function(&$value, $key) {
1212
if (is_string($value)) {
1313
$value = utf8_encode(self::clean($value));
1414
}
@@ -21,23 +21,23 @@ public function toJson($dados, $charset = 'UTF-8')
2121
public function clean($string)
2222
{
2323
$table = array(
24-
'?' => 'S', '?' => 's', '?' => 'Dj', '?' => 'dj', '?' => 'Z',
25-
'?' => 'z', '?' => 'C', '?' => 'c', '?' => 'C', '?' => 'c',
26-
'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A',
27-
'Å' => 'A', 'Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E',
28-
'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I',
29-
'Ï' => 'I', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O',
30-
'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U',
31-
'Û' => 'U', 'Ü' => 'U', 'Ý' => 'Y', 'Þ' => 'B', 'ß' => 'Ss',
32-
'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a',
33-
'å' => 'a', 'æ' => 'a', 'ç' => 'c', 'è' => 'e', 'é' => 'e',
34-
'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i',
35-
'ï' => 'i', 'ð' => 'o', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o',
36-
'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u',
37-
'ú' => 'u', 'û' => 'u', 'ý' => 'y', 'ý' => 'y', 'þ' => 'b',
38-
'ÿ' => 'y', '?' => 'R', '?' => 'r', 'ü' => 'u', 'º' => '',
39-
'ª' => '',
40-
);
24+
'?' => 'S', '?' => 's', '?' => 'Dj', '?' => 'dj', '?' => 'Z',
25+
'?' => 'z', '?' => 'C', '?' => 'c', '?' => 'C', '?' => 'c',
26+
'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A',
27+
'Å' => 'A', 'Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E',
28+
'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I',
29+
'Ï' => 'I', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O',
30+
'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U',
31+
'Û' => 'U', 'Ü' => 'U', 'Ý' => 'Y', 'Þ' => 'B', 'ß' => 'Ss',
32+
'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a',
33+
'å' => 'a', 'æ' => 'a', 'ç' => 'c', 'è' => 'e', 'é' => 'e',
34+
'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i',
35+
'ï' => 'i', 'ð' => 'o', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o',
36+
'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u',
37+
'ú' => 'u', 'û' => 'u', 'ý' => 'y', 'ý' => 'y', 'þ' => 'b',
38+
'ÿ' => 'y', '?' => 'R', '?' => 'r', 'ü' => 'u', 'º' => '',
39+
'ª' => '',
40+
);
4141

4242
$string = strtr($string, $table);
4343

core/model/Database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function __construct()
1616
$this->db_config = parse_ini_file('config.ini');
1717
}
1818

19-
$this->conn = new \PDO("mysql:host={$this->db_config['db_host']};".
19+
$this->conn = new \PDO("mysql:host={$this->db_config['db_host']};" .
2020
"dbname={$this->db_config['db_name']}",
2121
$this->db_config['db_user'],
2222
$this->db_config['db_pass']

core/model/Model.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private function where()
8585

8686
private function find()
8787
{
88-
$sql = "SELECT ".self::fields()." FROM {$this->table} ".self::where();
88+
$sql = "SELECT " . self::fields() . " FROM {$this->table} " . self::where();
8989

9090
$this->stmt = $this->conn->prepare($sql);
9191

@@ -117,7 +117,7 @@ private function insertQueryString()
117117
private function updateWhere($data)
118118
{
119119
$this->data['conditions'] = [$this->pk => $data[$this->pk]];
120-
$where = 'WHERE '.self::conditions('');
120+
$where = 'WHERE ' . self::conditions('');
121121
unset($data[$this->pk]);
122122

123123
return $where;
@@ -142,7 +142,7 @@ public function findOne($data)
142142
{
143143
$this->data['conditions'] = $data;
144144
return $this->fetch = $this->find()
145-
->stmt->fetch(PDO::FETCH_ASSOC);
145+
->stmt->fetch(PDO::FETCH_ASSOC);
146146
}
147147

148148
public function findById($id)
@@ -153,7 +153,7 @@ public function findById($id)
153153
public function exists($id)
154154
{
155155
if (is_array($id)) {
156-
return (self::findOne($id));
156+
return (self::findOne($id));
157157
}
158158

159159
return (self::findById($id));
@@ -187,7 +187,7 @@ public function save($data)
187187
$this->lastId = $data[$this->pk];
188188
}
189189

190-
if (! empty($this->count)) {
190+
if ( ! empty($this->count)) {
191191
return $this->update($data);
192192
}
193193

@@ -223,7 +223,7 @@ public function delete($data)
223223
{
224224
$this->data['conditions'] = $data;
225225

226-
$sql = "DELETE FROM {$this->table} ".self::where();
226+
$sql = "DELETE FROM {$this->table} " . self::where();
227227
$this->stmt = $this->conn->prepare($sql);
228228

229229
if ( ! empty($this->where)) {

index.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
$src = explode('/', $uri);
2929
$model = ucfirst($src[1]);
30-
$controller = $model.'Controller';
30+
$controller = $model . 'Controller';
3131
$method = (isset($src[2])) ? $src[2] : 'index';
3232

3333
if (isset($src[3]) && empty($the_request)) {
@@ -41,14 +41,14 @@
4141
$load_class = 'SimpleORM\app\controller\\' . $controller;
4242
$class = new $load_class();
4343
$set = $class->$method($the_request);
44-
} catch(Exception $e) {
45-
echo 'No '.$controller.' found for this route', $e->getMessage(), "\n";
44+
} catch (Exception $e) {
45+
echo 'No ' . $controller . ' found for this route', $e->getMessage(), "\n";
4646
}
4747

4848
/*
4949
* Declare all variables if passed in return
5050
*/
51-
if (!empty($set) && is_array($set)) {
51+
if ( ! empty($set) && is_array($set)) {
5252
foreach ($set as $k => $v) {
5353
${$k} = $v;
5454
}

0 commit comments

Comments
 (0)