From 61ac98d75e1f7e0cbe57b64b088f6a49118b426e Mon Sep 17 00:00:00 2001 From: David Schoenbauer Date: Thu, 1 Dec 2016 23:37:23 -0600 Subject: [PATCH] Release (#25) * adding initial coverall support (#14) * adding initial coverall support * adding back xdebug support to get coverage information * adding phpunit whitelist through config xml * Correcting whitelist * Correcting whitelist * More Tweaking * mer * mer * Locally reporting coverage * Updated Readme.md to included coverage badge * Updated Readme.md to included coverage badge * Add merge functionality (#15) * Updated license * Added merge with tests also resolves #8 * Updated documentation * updated documentation to apigen (#17) * Updated Exception Handling and added the remove function * Added missing test * Updated Exception Handling and added the remove function (#18) * Updated Exception Handling and added the remove function * Added missing test * updated documentation * Remove redundant interfaces (#23) * Removed redundant interfaces * updated documentation * updated more documentation * Updated Read me with examples * Remove redundant interfaces (#24) * Removed redundant interfaces * updated documentation * updated more documentation * Updated Read me with examples --- README.md | 52 ++++++++++++++----- ...oenbauer.DotNotation.ArrayDotNotation.html | 13 +++-- ...uer.DotNotation.Enum.ExceptionMessage.html | 22 ++++---- ...Notation.Exception.ExceptionInterface.html | 13 +++-- ...on.Exception.InvalidArgumentException.html | 6 ++- ...ation.Exception.PathNotArrayException.html | 10 ++-- ...ation.Exception.PathNotFoundException.html | 11 ++-- ...ion.Exception.TargetNotArrayException.html | 11 ++-- ...on.Exception.UnexpectedValueException.html | 4 +- ...ce-DSchoenbauer.DotNotation.Exception.html | 10 ++-- ...oenbauer.DotNotation.ArrayDotNotation.html | 46 ++++++++-------- ...uer.DotNotation.Enum.ExceptionMessage.html | 31 +++++++---- ...Notation.Exception.ExceptionInterface.html | 13 ++--- ...on.Exception.InvalidArgumentException.html | 15 +++--- ...ation.Exception.PathNotArrayException.html | 25 ++++----- ...ation.Exception.PathNotFoundException.html | 32 ++++++------ ...ion.Exception.TargetNotArrayException.html | 32 ++++++------ ...on.Exception.UnexpectedValueException.html | 13 ++--- src/DotNotation/ArrayDotNotation.php | 6 ++- src/DotNotation/Enum/ExceptionMessage.php | 13 +++++ .../Exception/ExceptionInterface.php | 1 + .../Exception/InvalidArgumentException.php | 3 +- .../Exception/PathNotArrayException.php | 5 +- .../Exception/PathNotFoundException.php | 6 ++- .../Exception/TargetNotArrayException.php | 6 ++- .../Exception/UnexpectedValueException.php | 1 + 26 files changed, 245 insertions(+), 155 deletions(-) diff --git a/README.md b/README.md index 0ba0d4d..7ab7480 100644 --- a/README.md +++ b/README.md @@ -21,44 +21,70 @@ Simplifies access to large array structures ## Example ``` - [ - 'default' => [ - 'user' => 'username', - 'password' => 's3cr3t' - ] +$mongoConnection = [ + 'mongo' => [ + 'default' => [ 'user' => 'username', 'password' => 's3cr3t' ] ] ]; $config = new ArrayDotNotation($mongoConnection); +``` +### GET +``` // Get plain value - $user = $config->get('mongo.default.user'); /* $user = 'username'; */ // Get array value - $mongoDefault = $config->get('mongo.default'); /* $mongoDefault = ['user' => 'username', 'password' => 's3cr3t']; */ +``` -// Set values - +### SET +```` $config = $config->set('mongo.numbers', [2, 3, 5, 7, 11]); $configDump = $config->getData(); /* $configDump = [ 'mongo' => [ + 'default' => [ 'user' => 'username', 'password' => 's3cr3t' ], 'numbers' => [2, 3, 5, 7, 11] ], 'title' => 'Dot Notation' ]; */ -``` +```` + +### MERGE +```` +$config = $config->merge('mongo.default', ['user' => 'otherUser','active' => true]); +$configDump = $config->getData(); +/* + $configDump = [ + 'mongo' => [ + 'default' => [ 'user' => 'otherUser', 'password' => 's3cr3t','active' => true ] + ], + 'title' => 'Dot Notation' + ]; +*/ +```` + +### REMOVE +```` +$config = $config->remove('mongo.default.user'); +$configDump = $config->getData(); +/* + $configDump = [ + 'mongo' => [ + 'default' => [ 'password' => 's3cr3t' ] + ], + 'title' => 'Dot Notation' + ]; +*/ +```` diff --git a/docs/class-DSchoenbauer.DotNotation.ArrayDotNotation.html b/docs/class-DSchoenbauer.DotNotation.ArrayDotNotation.html index 48a8818..0b59099 100644 --- a/docs/class-DSchoenbauer.DotNotation.ArrayDotNotation.html +++ b/docs/class-DSchoenbauer.DotNotation.ArrayDotNotation.html @@ -114,7 +114,7 @@

Class ArrayDotNotation

David Schoenbauer
Version: 1.0.1
- Located at DotNotation/ArrayDotNotation.php + Located at DotNotation/ArrayDotNotation.php
@@ -551,14 +551,16 @@

Since

# - recursiveRemove( array & $data, array $keys ) + recursiveRemove( array & $data, array $keys )
-

Transverses the keys array until it reaches the appropriate key in the data array and then deletes the value from the key.

+

Transverses the keys array until it reaches the appropriate key in the +data array and then deletes the value from the key.

@@ -133,15 +135,15 @@

Class ExceptionMessage

string - PATH_NOT_FOUND + PATH_NOT_FOUND
- +

Message to be used in PathNotFoundException

@@ -157,15 +159,15 @@

Class ExceptionMessage

string - PATH_NOT_ARRAY + PATH_NOT_ARRAY
- +

Message to be used in PathNotArrayException

@@ -181,15 +183,15 @@

Class ExceptionMessage

string - TARGET_NOT_ARRAY + TARGET_NOT_ARRAY
- +

Message to be used in TargetNotArrayException

diff --git a/docs/class-DSchoenbauer.DotNotation.Exception.ExceptionInterface.html b/docs/class-DSchoenbauer.DotNotation.Exception.ExceptionInterface.html index 07878cf..8bedea4 100644 --- a/docs/class-DSchoenbauer.DotNotation.Exception.ExceptionInterface.html +++ b/docs/class-DSchoenbauer.DotNotation.Exception.ExceptionInterface.html @@ -111,12 +111,15 @@

Interface ExceptionInterface

Direct known implementers

DSchoenbauer\DotNotation\Exception\InvalidArgumentException, - DSchoenbauer\DotNotation\Exception\PathNotArrayException, - DSchoenbauer\DotNotation\Exception\PathNotFoundException, - DSchoenbauer\DotNotation\Exception\TargetNotArrayException, DSchoenbauer\DotNotation\Exception\UnexpectedValueException
+
+

Indirect known implementers

+ DSchoenbauer\DotNotation\Exception\PathNotArrayException, + DSchoenbauer\DotNotation\Exception\PathNotFoundException, + DSchoenbauer\DotNotation\Exception\TargetNotArrayException +
@@ -128,7 +131,9 @@

Direct known implementers

Author: David Schoenbauer dschoenbauer@gmail.com
- Located at DotNotation/Exception/ExceptionInterface.php + Since: + 1.1.0
+ Located at DotNotation/Exception/ExceptionInterface.php
diff --git a/docs/class-DSchoenbauer.DotNotation.Exception.InvalidArgumentException.html b/docs/class-DSchoenbauer.DotNotation.Exception.InvalidArgumentException.html index 667516b..ce5cc9c 100644 --- a/docs/class-DSchoenbauer.DotNotation.Exception.InvalidArgumentException.html +++ b/docs/class-DSchoenbauer.DotNotation.Exception.InvalidArgumentException.html @@ -101,7 +101,7 @@

Class InvalidArgumentException

-

Description of InvalidArgumentException

+

Exception thrown if an argument is not of the expected type.

@@ -147,7 +147,9 @@

Class InvalidArgumentException

Author: David Schoenbauer dschoenbauer@gmail.com
- Located at DotNotation/Exception/InvalidArgumentException.php + Since: + 1.1.0
+ Located at DotNotation/Exception/InvalidArgumentException.php
diff --git a/docs/class-DSchoenbauer.DotNotation.Exception.PathNotArrayException.html b/docs/class-DSchoenbauer.DotNotation.Exception.PathNotArrayException.html index 6dfa599..5c37c3f 100644 --- a/docs/class-DSchoenbauer.DotNotation.Exception.PathNotArrayException.html +++ b/docs/class-DSchoenbauer.DotNotation.Exception.PathNotArrayException.html @@ -101,7 +101,7 @@

Class PathNotArrayException

-

Description of PathNotArrayException

+

Exception thrown when a node along the dot notation is found not to be an array

@@ -134,8 +134,6 @@

Class PathNotArrayException

Extended by DSchoenbauer\DotNotation\Exception\PathNotArrayException - implements - DSchoenbauer\DotNotation\Exception\ExceptionInterface
@@ -156,7 +154,9 @@

Class PathNotArrayException

Author: David Schoenbauer dschoenbauer@gmail.com
- Located at DotNotation/Exception/PathNotArrayException.php + Since: + 1.1.0
+ Located at DotNotation/Exception/PathNotArrayException.php
@@ -176,7 +176,7 @@

Class PathNotArrayException

# - __construct( $key = "", $message = "", $code = 0, $previous = null ) + __construct( $key = "", $message = "", $code = 0, $previous = null )
diff --git a/docs/class-DSchoenbauer.DotNotation.Exception.PathNotFoundException.html b/docs/class-DSchoenbauer.DotNotation.Exception.PathNotFoundException.html index 4f1201d..90951ec 100644 --- a/docs/class-DSchoenbauer.DotNotation.Exception.PathNotFoundException.html +++ b/docs/class-DSchoenbauer.DotNotation.Exception.PathNotFoundException.html @@ -101,7 +101,8 @@

Class PathNotFoundException

-

Description of PathNotFoundException

+

Exception thrown when the dot notation path is not found in the +target data structure

@@ -134,8 +135,6 @@

Class PathNotFoundException

Extended by DSchoenbauer\DotNotation\Exception\PathNotFoundException - implements - DSchoenbauer\DotNotation\Exception\ExceptionInterface
@@ -156,7 +155,9 @@

Class PathNotFoundException

Author: David Schoenbauer dschoenbauer@gmail.com
- Located at DotNotation/Exception/PathNotFoundException.php + Since: + 1.1.0
+ Located at DotNotation/Exception/PathNotFoundException.php
@@ -176,7 +177,7 @@

Class PathNotFoundException

# - __construct( $key = "", $message = "", $code = 0, $previous = null ) + __construct( $key = "", $message = "", $code = 0, $previous = null )
diff --git a/docs/class-DSchoenbauer.DotNotation.Exception.TargetNotArrayException.html b/docs/class-DSchoenbauer.DotNotation.Exception.TargetNotArrayException.html index 5fcc5cc..3821c72 100644 --- a/docs/class-DSchoenbauer.DotNotation.Exception.TargetNotArrayException.html +++ b/docs/class-DSchoenbauer.DotNotation.Exception.TargetNotArrayException.html @@ -101,7 +101,8 @@

Class TargetNotArrayException

-

Description of TargetNotAnArrayException

+

Exception thrown when the final node in the dot notation path needs to be an +array but it is not.

@@ -134,8 +135,6 @@

Class TargetNotArrayException

Extended by DSchoenbauer\DotNotation\Exception\TargetNotArrayException - implements - DSchoenbauer\DotNotation\Exception\ExceptionInterface
@@ -156,7 +155,9 @@

Class TargetNotArrayException

Author: David Schoenbauer dschoenbauer@gmail.com
- Located at DotNotation/Exception/TargetNotArrayException.php + Since: + 1.1.0
+ Located at DotNotation/Exception/TargetNotArrayException.php
@@ -176,7 +177,7 @@

Class TargetNotArrayException

# - __construct( $key = "", $message = "", $code = 0, $previous = null ) + __construct( $key = "", $message = "", $code = 0, $previous = null )
diff --git a/docs/class-DSchoenbauer.DotNotation.Exception.UnexpectedValueException.html b/docs/class-DSchoenbauer.DotNotation.Exception.UnexpectedValueException.html index c42777c..7fa01dc 100644 --- a/docs/class-DSchoenbauer.DotNotation.Exception.UnexpectedValueException.html +++ b/docs/class-DSchoenbauer.DotNotation.Exception.UnexpectedValueException.html @@ -156,7 +156,9 @@

Direct known subclasses

Author: David Schoenbauer dschoenbauer@gmail.com
- Located at DotNotation/Exception/UnexpectedValueException.php + Since: + 1.1.0
+ Located at DotNotation/Exception/UnexpectedValueException.php
diff --git a/docs/namespace-DSchoenbauer.DotNotation.Exception.html b/docs/namespace-DSchoenbauer.DotNotation.Exception.html index 68e206a..fdfd19e 100644 --- a/docs/namespace-DSchoenbauer.DotNotation.Exception.html +++ b/docs/namespace-DSchoenbauer.DotNotation.Exception.html @@ -114,19 +114,21 @@

Namespace DSchoenbauer\InvalidArgumentException - Description of InvalidArgumentException + Exception thrown if an argument is not of the expected type. PathNotArrayException - Description of PathNotArrayException + Exception thrown when a node along the dot notation is found not to be an array PathNotFoundException - Description of PathNotFoundException +

Exception thrown when the dot notation path is not found in the +target data structure

TargetNotArrayException - Description of TargetNotAnArrayException +

Exception thrown when the final node in the dot notation path needs to be an +array but it is not.

UnexpectedValueException diff --git a/docs/source-class-DSchoenbauer.DotNotation.ArrayDotNotation.html b/docs/source-class-DSchoenbauer.DotNotation.ArrayDotNotation.html index 62c9ff2..5034efa 100644 --- a/docs/source-class-DSchoenbauer.DotNotation.ArrayDotNotation.html +++ b/docs/source-class-DSchoenbauer.DotNotation.ArrayDotNotation.html @@ -291,28 +291,30 @@

Exceptions

188: } 189: 190: /** -191: * Transverses the keys array until it reaches the appropriate key in the data array and then deletes the value from the key. -192: * -193: * @since 1.1.0 -194: * @param array $data data to be traversed -195: * @param array $keys the remaining keys of focus for the data array -196: * @throws UnexpectedValueException if a value in the dot notation path is not an array -197: */ -198: protected function recursiveRemove(array &$data, array $keys) { -199: $key = array_shift($keys); -200: if (!array_key_exists($key, $data)) { -201: throw new PathNotFoundException($key); -202: } elseif ($key && count($keys) == 0) { //Last Key -203: unset($data[$key]); -204: } elseif (!is_array($data[$key])) { -205: throw new PathNotArrayException($key); -206: } else { -207: $this->recursiveRemove($data[$key], $keys); -208: } -209: } -210: -211: } -212: +191: * Transverses the keys array until it reaches the appropriate key in the +192: * data array and then deletes the value from the key. +193: * +194: * @since 1.1.0 +195: * @param array $data data to be traversed +196: * @param array $keys the remaining keys of focus for the data array +197: * @throws UnexpectedValueException if a value in the dot notation path is +198: * not an array +199: */ +200: protected function recursiveRemove(array &$data, array $keys) { +201: $key = array_shift($keys); +202: if (!array_key_exists($key, $data)) { +203: throw new PathNotFoundException($key); +204: } elseif ($key && count($keys) == 0) { //Last Key +205: unset($data[$key]); +206: } elseif (!is_array($data[$key])) { +207: throw new PathNotArrayException($key); +208: } else { +209: $this->recursiveRemove($data[$key], $keys); +210: } +211: } +212: +213: } +214: