Skip to content
This repository was archived by the owner on May 12, 2022. It is now read-only.

Commit 736ce65

Browse files
author
Nik Barham
committed
Minor Style Cleaning
1 parent 506fa48 commit 736ce65

File tree

5 files changed

+32
-30
lines changed

5 files changed

+32
-30
lines changed

src/Database/QueryBuilder.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,18 +277,18 @@ public function join($table, $rawtype = null)
277277
$type = 'JOIN';
278278
if ($rawtype) {
279279
switch (strtolower($rawtype)) {
280-
case 'left':
281-
$type = 'LEFT JOIN';
282-
break;
283-
case 'left outer':
284-
$type = 'LEFT OUTER JOIN';
285-
break;
286-
case 'cross':
287-
$type = 'CROSS JOIN';
288-
break;
289-
default:
290-
throw new Exception\QueryBuilder('Unknown Join Type');
291-
}
280+
case 'left':
281+
$type = 'LEFT JOIN';
282+
break;
283+
case 'left outer':
284+
$type = 'LEFT OUTER JOIN';
285+
break;
286+
case 'cross':
287+
$type = 'CROSS JOIN';
288+
break;
289+
default:
290+
throw new Exception\QueryBuilder('Unknown Join Type');
291+
}
292292
}
293293

294294
$this->joins[] = ['table' => $table, 'type' => $type, 'where' => [], 'on' => []];

src/Exception/Model.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ private function makeMessage($code, $data)
2020
case 'NO_GENERATED_SCHEMA':
2121
return 'NO_GENERATED_SCHEMA: Could not find a schema definition for namespace: ' . $data;
2222
case 'NO_SCHEMA':
23-
list($class_or_table, $normalised, $class) = $data;
24-
return 'NO_SCHEMA: Could not find a schema definition for this object (' . $class_or_table . '). Are you sure the classname and table are the same (case-insensitive). Otherwise, try calling Model::generate_schema(true) to refresh the schema cache.';
23+
list($classOrTable, $normalised, $class) = $data;
24+
return 'NO_SCHEMA: Could not find a schema definition for this object (' . $classOrTable . '). Are you sure the classname and table are the same (case-insensitive). Otherwise, try calling Model::generate_schema(true) to refresh the schema cache.';
2525

2626
case 'MODEL_DATA:SET_WHEN_LOCKED':
2727
list($column, $value) = $data;
@@ -91,8 +91,8 @@ private function makeMessage($code, $data)
9191
return 'MODEL_DATA:CANNOT_DELETE_UNCOMMITED_DATA: You cannot mark a Data object for deletion if it does not represent an existing row in the database.';
9292

9393
case 'MODEL_DATA:INCORRECT_MODEL_FOR_RELATIONSHIP':
94-
list($column, $supplied_table, $expected_table) = $data;
95-
return 'MODEL_DATA:INCORRECT_MODEL_FOR_RELATIONSHIP: Property "'.$column.'" expected a Model relating to table "'.$expected_table.'" but a Model for "'.$supplied_table.'" was given instead.';
94+
list($column, $suppliedTable, $expectedTable) = $data;
95+
return 'MODEL_DATA:INCORRECT_MODEL_FOR_RELATIONSHIP: Property "'.$column.'" expected a Model relating to table "'.$expectedTable.'" but a Model for "'.$suppliedTable.'" was given instead.';
9696
default:
9797
return "Unknown error code ({$code})";
9898
}

src/Orm/DataAccess.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ public function commit($mode, $table, $id, $data, $externalData, $schema)
2323

2424
// Insert/Update the data, and store the insert id into a variable
2525
if ($mode == 'delete') {
26-
$q = QueryBuilder::delete($table, ['id' => $id]);
27-
$query->sql($q);
26+
$sql = QueryBuilder::delete($table, ['id' => $id]);
27+
$query->sql($sql);
2828
} elseif ($mode == 'insert') {
29-
$q = QueryBuilder::insert($table, $data);
30-
$query->sql($q)->sql("SELECT last_insert_id() into @id");
29+
$sql = QueryBuilder::insert($table, $data);
30+
$query->sql($sql)->sql("SELECT last_insert_id() into @id");
3131
} elseif ($mode == 'update') {
32-
$q = QueryBuilder::update($table, $data)->where(['id' => $id]);
33-
$query->sql($q)->sql("SELECT {$id} into @id");
32+
$sql = QueryBuilder::update($table, $data)->where(['id' => $id]);
33+
$query->sql($sql)->sql("SELECT {$id} into @id");
3434
}
3535

3636
if ($mode != 'delete') {
@@ -66,7 +66,7 @@ public function commit($mode, $table, $id, $data, $externalData, $schema)
6666
}
6767

6868
$query->transaction();
69-
$values = $query->execute();
69+
$query->execute();
7070
$query->commit();
7171

7272
// Don't return anything if we just deleted this row.

src/Orm/Model.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public function __sleep()
367367
public function __wakeup()
368368
{
369369
// Store the object in the object cache
370-
Model::$instance[$namespace][$this->table][strtolower(get_called_class())][$this->id] = $this;
370+
Model::$instance[$this->namespace][$this->table][strtolower(get_called_class())][$this->id] = $this;
371371

372372
if (!$this->_data) {
373373
// If we don't have a data object, then this object wasn't cached, regenerate the Data object.

src/Orm/SchemaGenerator.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
class SchemaGenerator implements SchemaGeneratorInterface
1212
{
13+
protected $connection;
14+
1315
public function __construct(ConnectionInterface $connection)
1416
{
1517
$this->connection = $connection;
@@ -72,12 +74,12 @@ public function generate()
7274
// Otherwise, append the column name to the table name to make sure it is unique.
7375
// (e.g "your_account" table and "my_account_id" -> your_account_my_account)
7476
if ($columnRoot == $row['referenced_table_name']) {
75-
$property_name = Schema::underscoreCase($tableName);
77+
$propertyName = Schema::underscoreCase($tableName);
7678
} else {
77-
$property_name = Schema::underscoreCase($tableName) . '_' . $columnRoot;
79+
$propertyName = Schema::underscoreCase($tableName) . '_' . $columnRoot;
7880
}
7981

80-
$model[$refTableName]['one-to-many'][$property_name] = array('table' => $tableName, 'column_name' => $row['column_name']);
82+
$model[$refTableName]['one-to-many'][$propertyName] = array('table' => $tableName, 'column_name' => $row['column_name']);
8183
}
8284
}
8385
}
@@ -97,18 +99,18 @@ public function generate()
9799
// If the column name is named based on the foreign table name, then use the pivot table name as the property name
98100
// This is the normal/usual case
99101
if ($table['column'] == Schema::underscoreCase($table['table']) . '_id') {
100-
$property_name = Schema::underscoreCase($pivottablename);
102+
$propertyName = Schema::underscoreCase($pivottablename);
101103
} else {
102104
// Else append the column name to the pivot table name.
103105
// This is mostly for when a pivot table references the same table twice, and so
104106
// needs to have a unique name for at least one of the columns (which is not based on the table name)
105-
$property_name = Schema::underscoreCase($pivottablename) . '_' . $table['column_raw'];
107+
$propertyName = Schema::underscoreCase($pivottablename) . '_' . $table['column_raw'];
106108
}
107109

108110
// Outersect of tables to create an array of all OTHER foreign keys in this table, for this foreign key.
109111
$othertables = array_values(array_diff_assoc($tableinfo, array($i => $table)));
110112

111-
$model[ $table['table'] ][ 'many-to-many' ][ $property_name ] = array(
113+
$model[ $table['table'] ][ 'many-to-many' ][ $propertyName ] = array(
112114
'pivot' => $pivottablename,
113115
'connections' => $othertables,
114116
'id' => $table['column'],

0 commit comments

Comments
 (0)