Skip to content

Commit

Permalink
Добавлено описание методов
Browse files Browse the repository at this point in the history
  • Loading branch information
petrgrishin committed May 4, 2014
1 parent df3752f commit c524ea8
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/ArrayAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,35 @@ class ArrayAccess {
/** @var string */
private $pathDelimiter;

/**
* @return string
*/
public static function className() {
return get_called_class();
}

/**
* @param array|null $data
* @param string|null $pathDelimiter
* @return static
*/
public static function create(array $data = null, $pathDelimiter = null) {
return new static($data, $pathDelimiter);
}

/**
* @param array|null $data
* @param string|null $pathDelimiter
*/
public function __construct(array $data = null, $pathDelimiter = null) {
$this->setArray($data ?: array());
$this->setPathDelimiter($pathDelimiter ?: '.');
}

/**
* @param string $delimiter
* @return $this
*/
public function setPathDelimiter($delimiter) {
$this->pathDelimiter = $delimiter;
return $this;
Expand All @@ -50,7 +66,7 @@ public function getArray() {

/**
* @param string $path
* @param null|string $defaultValue
* @param mixed $defaultValue
* @throws Exception\ArrayAccessException
* @return mixed
*/
Expand Down Expand Up @@ -81,8 +97,8 @@ public function getValue($path, $defaultValue = null) {
}

/**
* @param $path
* @param $value
* @param string $path
* @param mixed $value
* @return $this
* @throws Exception\ArrayAccessException
*/
Expand All @@ -103,6 +119,11 @@ public function setValue($path, $value) {
return $this;
}

/**
* @param string $path
* @return $this
* @throws Exception\ArrayAccessException
*/
public function remove($path) {
$array = & $this->data;
$keys = explode($this->pathDelimiter, $path);
Expand Down

0 comments on commit c524ea8

Please sign in to comment.