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

Commit 66fa115

Browse files
author
Nik Barham
committed
Minor style updates
1 parent 52e93c3 commit 66fa115

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

src/Orm/Model.php

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
use Automatorm\Exception;
55

66
/* MVC Model Class giving a lightweight ORM interface with an indirect active record pattern.
7-
* The rationale for this superclass is to make it trivial to create an object representing a single row in a database table (and a class
8-
* representing a database table).
7+
* The rationale for this superclass is to make it trivial to create an object representing
8+
* a single row in a database table (and a class representing a database table).
99
*
1010
* Features:
1111
* * Auto generation of object properties - TableName::get($id)->column_name syntax
@@ -24,8 +24,8 @@ class Model implements \JsonSerializable
2424
// Flags
2525
const COUNT_ONLY = 1;
2626

27-
public static $tablename; // Override table associated with this class
28-
protected static $instance; // An internal store of already created objects so that objects for each row only get created once
27+
public static $tablename; // Override table associated with this class
28+
protected static $instance; // An internal store of created objects so that objects for each row only get created once
2929

3030
/* PUBLIC CONSTRUCTION METHODS */
3131
/**
@@ -146,7 +146,7 @@ final public static function factory($where, $classOrTablename = null, $schema =
146146
final public static function factoryObjectCache($ids, $classOrTable = null, Schema $schema = null, $forceRefresh = false)
147147
{
148148
$schema = $schema ?: Schema::get(static::getNamespace());
149-
list($class, $table) = $schema->guessContext($classOrTable ?: get_called_class());
149+
list(,$table) = $schema->guessContext($classOrTable ?: get_called_class());
150150
$namespace = $schema->namespace;
151151

152152
// If we have a single id
@@ -200,21 +200,13 @@ final public static function factoryObjectCache($ids, $classOrTable = null, Sche
200200
// Get data from database from which we can construct Model objects
201201
final public static function factoryData($where, $table, Schema $schema, array $options = null)
202202
{
203-
return $schema->connection->getDataAccessor()->getData(
204-
$table,
205-
$where,
206-
$options
207-
);
203+
return $schema->connection->getDataAccessor()->getData($table, $where, $options);
208204
}
209205

210206
// Get data from database from which we can construct Model objects
211207
final public static function factoryDataCount($where, $table, Schema $schema, array $options = null)
212208
{
213-
return $schema->connection->getDataAccessor()->getDataCount(
214-
$table,
215-
$where,
216-
$options
217-
);
209+
return $schema->connection->getDataAccessor()->getDataCount($table, $where, $options);
218210
}
219211

220212
// Return an empty Model_Data object for this class/table so that a new object can be constructed (and a new row entered in the table).
@@ -382,7 +374,7 @@ public function __wakeup()
382374

383375
final public function data()
384376
{
385-
return clone $this->_data;
377+
return clone $this->_data;
386378
}
387379

388380
final public function dataOriginal()
@@ -403,7 +395,7 @@ final public function dataClearCache()
403395
$modelschema = $this->_data->getModel();
404396

405397
// Clean out cached column data
406-
foreach ($modelschema['columns'] as $column => $type) {
398+
foreach (array_keys($modelschema['columns']) as $column) {
407399
if ($column != 'id' && property_exists($this, $column)) {
408400
unset($this->{$column});
409401
}
@@ -419,7 +411,7 @@ final public function dataClearCache()
419411

420412
// Clean out cached external data
421413
$foreignkeys = (array) $modelschema['one-to-one'] + (array) $modelschema['one-to-many'] + (array) $modelschema['many-to-many'] + (array) $modelschema['many-to-one'];
422-
foreach ($foreignkeys as $column => $value) {
414+
foreach (array_keys($foreignkeys) as $column) {
423415
if ($column && $column != 'id') {
424416
unset($this->{$column});
425417
}

0 commit comments

Comments
 (0)