/**
  * merge data from a container, using dot.notation.support to identify
  * the data to remove
  *
  * @param  mixed $container
  *         the container we want to remove from
  * @param  string $path
  *         the dot.notation.support path to the data to remove
  * @return void
  */
 public static function from(&$container, $path)
 {
     // defensive programming!
     RequireAnyOneOf::check([new IsAssignable(), new IsIndexable()], [$container], E4xx_UnsupportedType::class);
     RequireDotNotationPath::check($path);
     // find the point where we want to remove the data from
     list($firstPart, $finalPart) = self::splitPathInTwo($path);
     $leaf =& DescendDotNotationPath::into($container, $firstPart);
     // remove it
     RemoveProperty::from($leaf, $finalPart);
 }
 /**
  * @covers ::getPathFromRoot
  * @dataProvider provideUnextendablePaths
  * @expectedException GanbaroDigital\DataContainers\Exceptions\E4xx_CannotDescendPath
  */
 public function testThrowsExceptionWhenAttemptingToExtendNonContainer($container, $path)
 {
     // ----------------------------------------------------------------
     // setup your test
     // ----------------------------------------------------------------
     // perform the change
     DescendDotNotationPath::into($container, $path, []);
 }
 /**
  * does $path point to a valid piece of data inside $container?
  *
  * @param  object $container
  *         the container to look inside
  * @param  string $path
  *         the dot.notation.support path to walk
  * @return boolean
  *         TRUE if $path points to a vlaid piece of data
  *         FALSE otherwise
  */
 public static function inObject($container, $path)
 {
     // defensive programming!
     RequireAssignable::check($container, E4xx_UnsupportedType::class);
     RequireAnyOneOf::check([new IsDotNotationPath(), new IsStringy()], [$path], E4xx_NotDotNotationPath::class);
     try {
         DescendDotNotationPath::intoObject($container, $path);
         return true;
     } catch (E4xx_NoSuchIndex $e) {
         return false;
     } catch (E4xx_NoSuchProperty $e) {
         return false;
     }
 }
 /**
  * merge their data into our object, using dot.notation.support to
  * find the point where the merge starts
  *
  * @param  object $obj
  *         the object that we want to merge into
  * @param  string $path
  *         the dot.notation.support path to where the merge should start
  * @param  mixed $value
  *         the data that we want to merge from
  * @param  array|callable|string|null
  *         if $path goes beyond what exists in $ours, how do we want to
  *         extend $ours?
  * @return void
  */
 public static function intoObject($obj, $path, $value, $extendingItem = null)
 {
     // robustness!
     RequireAssignable::check($obj, E4xx_UnsupportedType::class);
     RequireDotNotationPath::check($path);
     // find the point where we want to merge
     list($firstPart, $finalPart) = self::splitPathInTwo($path);
     if ($firstPart !== null) {
         $leaf =& DescendDotNotationPath::intoObject($obj, $firstPart, $extendingItem);
     } else {
         $leaf = $obj;
     }
     // merge it
     MergeIntoProperty::of($leaf, $finalPart, $value);
 }
 /**
  * extract a value from an object, using dot.notation.support
  *
  * @param  object $obj
  *         the object to extract from
  * @param  string $property
  *         the dot.notation.support path to walk
  * @return mixed
  *         whatever we find when we walk the path
  */
 public static function fromObject($obj, $property)
 {
     // robustness!
     RequireAssignable::check($obj, E4xx_UnsupportedType::class);
     return DescendDotNotationPath::intoObject($obj, $property);
 }