Skip to content

Commit

Permalink
Document: Refactored __get code to use if conditions instead of a swi…
Browse files Browse the repository at this point in the history
…tch.

QA #1: Removed an unused reference (Collection)
QA #2: Removed newline after php closing tag
  • Loading branch information
Howard3 authored and nateabele committed Jun 11, 2011
1 parent 5ea70c5 commit 9191229
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions data/entity/Document.php
Expand Up @@ -8,7 +8,6 @@

namespace lithium\data\entity;

use lithium\util\Collection;
use UnexpectedValueException;

/**
Expand Down Expand Up @@ -133,18 +132,17 @@ public function &__get($name) {
$conn = $model ? $model::connection() : null;

if ($model && $conn && $schema = $model::schema($name)) {
switch (true) {
case (isset($this->_updated[$name])) :
return $this->_updated[$name];
case (!isset($this->_data[$name])) :
$schema = array($name => $schema);
$pathKey = $this->_pathKey ? $this->_pathKey : null;
$options = compact('pathKey', 'schema') + array('first' => true);
if (($value = $conn->cast($this, array($name => null), $options)) !== null) {
$this->_data[$name] = $value;
return $this->_data[$name];
}
break;
if (isset($this->_updated[$name])) {
return $this->_updated[$name];
}
if (!isset($this->_data[$name])) {
$schema = array($name => $schema);
$pathKey = $this->_pathKey ? $this->_pathKey : null;
$options = compact('pathKey', 'schema') + array('first' => true);
if (($value = $conn->cast($this, array($name => null), $options)) !== null) {
$this->_data[$name] = $value;
return $this->_data[$name];
}
}
}
return parent::__get($name);
Expand Down Expand Up @@ -455,4 +453,4 @@ public function increment($field, $value = 1) {
}
}

?>
?>

0 comments on commit 9191229

Please sign in to comment.