Skip to content

Commit

Permalink
Reverting some changes till i can look close
Browse files Browse the repository at this point in the history
  • Loading branch information
stygiansabyss committed Aug 25, 2016
1 parent b7bc4de commit 4f203a0
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/NukaCode/Database/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ public function __call($method, $args)
*/
public function insertAfter($value, $afterKey)
{
$newObject = new self();
$new_object = new self();

foreach ((array)$this->items as $k => $v) {
if ($afterKey == $k) {
$newObject->add($value);
$new_object->add($value);
}

$newObject->add($v);
$new_object->add($v);
}

$this->items = $newObject->items;
$this->items = $new_object->items;

return $this;
}
Expand All @@ -112,12 +112,12 @@ public function insertAfter($value, $afterKey)
* Turn a collection into a drop down for an html select element.
*
* @param string $firstOptionText Text for the first object in the select array.
* @param string $idColumn The column to use for the id column in the option element.
* @param string $id The column to use for the id column in the option element.
* @param string $name The column to use for the name column in the option element.
*
* @return array The new select element array.
*/
public function toSelectArray($firstOptionText = 'Select one', $idColumn = 'id', $name = 'name')
public function toSelectArray($firstOptionText = 'Select one', $id = 'id', $name = 'name')
{
$selectArray = [];

Expand All @@ -126,7 +126,7 @@ public function toSelectArray($firstOptionText = 'Select one', $idColumn = 'id',
}

foreach ($this->items as $item) {
$selectArray[$item->{$idColumn}] = $item->{$name};
$selectArray[$item->{$id}] = $item->{$name};
}

return $selectArray;
Expand Down Expand Up @@ -252,11 +252,11 @@ protected function getWhere($column, $operator, $value = null, $inverse = false,
{
$output = clone $this;
foreach ($output->items as $key => $item) {
// No tap direct object access
$forget = $this->whereObject($item, $column, $operator, $value, $inverse);

if (strstr($column, '->')) {
$forget = $this->handleMultiTap($item, $column, $value, $operator, $inverse);
} else {
// No tap direct object access
$forget = $this->whereObject($item, $column, $operator, $value, $inverse);
}

if ($forget == true) {
Expand Down Expand Up @@ -291,10 +291,10 @@ private function handleMultiTap($item, $column, $value, $operator, $inverse)
// The column has a tap that ends in a collection.
return $this->whereObject($subObject, $columnToSearch, $operator, $value, $inverse);
}
} else {
// The column has a tap that ends in direct access
return $this->whereObject($objectToSearch, $columnToSearch, $operator, $value, $inverse);
}

// The column has a tap that ends in direct access
return $this->whereObject($objectToSearch, $columnToSearch, $operator, $value, $inverse);
}

/**
Expand All @@ -310,7 +310,7 @@ private function tapThroughObjects($column, $item)
$objectToSearch = $item;
$columnToSearch = array_pop($taps);

foreach ($taps as $tap) {
foreach ($taps as $tapKey => $tap) {
// Keep tapping till we hit the last object.
$objectToSearch = $objectToSearch->$tap;
}
Expand Down Expand Up @@ -364,10 +364,10 @@ private function getWhereBetween($object, $column, $value, $inverse)
if ($object->$column < $value[0] || $object->$column > $value[1]) {
return true;
}
}

if ($object->$column >= $value[0] && $object->$column <= $value[1]) {
return true;
} else {
if ($object->$column >= $value[0] && $object->$column <= $value[1]) {
return true;
}
}

return false;
Expand Down

0 comments on commit 4f203a0

Please sign in to comment.