-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
ArrayObject
and make Object
not to implement ArrayAccess
in…
…terface. Remove Toolbox dependency.
- Loading branch information
Showing
7 changed files
with
316 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
/** | ||
* @package Grav\Framework\Object | ||
* | ||
* @copyright Copyright (C) 2014 - 2017 RocketTheme, LLC. All rights reserved. | ||
* @license MIT License; see LICENSE file for details. | ||
*/ | ||
|
||
namespace Grav\Framework\Object; | ||
|
||
/** | ||
* Object class. | ||
* | ||
* @package Grav\Framework\Object | ||
*/ | ||
class ArrayObject extends Object implements \ArrayAccess | ||
{ | ||
/** | ||
* Whether or not an offset exists. | ||
* | ||
* @param mixed $offset An offset to check for. | ||
* @return bool Returns TRUE on success or FALSE on failure. | ||
*/ | ||
public function offsetExists($offset) | ||
{ | ||
if (strpos($offset, '.') !== false) { | ||
$test = new \stdClass(); | ||
return $this->getProperty($offset, $test) !== $test; | ||
} | ||
|
||
return $this->__isset($offset); | ||
} | ||
|
||
/** | ||
* Returns the value at specified offset. | ||
* | ||
* @param mixed $offset The offset to retrieve. | ||
* @return mixed Can return all value types. | ||
*/ | ||
public function offsetGet($offset) | ||
{ | ||
return $this->getProperty($offset); | ||
} | ||
|
||
/** | ||
* Assigns a value to the specified offset. | ||
* | ||
* @param mixed $offset The offset to assign the value to. | ||
* @param mixed $value The value to set. | ||
*/ | ||
public function offsetSet($offset, $value) | ||
{ | ||
$this->setProperty($offset, $value); | ||
} | ||
|
||
/** | ||
* Unsets an offset. | ||
* | ||
* @param mixed $offset The offset to unset. | ||
*/ | ||
public function offsetUnset($offset) | ||
{ | ||
if (strpos($offset, '.') !== false) { | ||
$this->setProperty($offset, null); | ||
} else { | ||
$this->__unset($offset); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.