/**
  * @covers ::intoObject
  * @dataProvider provideNonAssignable
  * @expectedException GanbaroDigital\DataContainers\Exceptions\E4xx_UnsupportedType
  */
 public function testThrowsExceptionWhenNonAssignablePassedIntoIsObject($data)
 {
     // ----------------------------------------------------------------
     // setup your test
     // ----------------------------------------------------------------
     // perform the change
     ShouldOverwrite::intoObject($data, 'doesNotMatter', []);
 }
 /**
  * merge a single key into our array
  *
  * @param  array &$ours
  *         the array to merge into
  * @param  mixed $key
  *         the array key to merge into
  * @param  mixed $value
  *         the data to merge in
  * @return void
  */
 private static function mergeKeyIntoArray(&$ours, $key, $value)
 {
     // general case - overwrite because merging isn't possible
     if (ShouldOverwrite::intoArray($ours, $key, $value)) {
         $ours[$key] = $value;
         return;
     }
     // special case - we are merging into an object
     if (is_object($ours[$key])) {
         MergeIntoAssignable::from($ours[$key], $value);
         return;
     }
     // at this point, we are merging into an array, using recursion
     // for which I am going to hell
     MergeIntoIndexable::from($ours[$key], $value);
 }
 /**
  * merge their data into one of our object's properties
  *
  * @param  object &$obj
  *         the object that we want to merge into
  * @param  string $property
  *         the property to merge into
  * @param  mixed $value
  *         the data that we want to merge from
  * @return void
  */
 public static function ofObject($obj, $property, $value)
 {
     // robustness!
     RequireAssignable::check($obj, E4xx_UnsupportedType::class);
     // easiest case - no clash
     if (ShouldOverwrite::intoObject($obj, $property, $value)) {
         $obj->{$property} = $value;
         return;
     }
     // special case - we are merging into an object
     if (is_object($obj->{$property})) {
         MergeIntoAssignable::from($obj->{$property}, $value);
         return;
     }
     // if we get here, then we must be merging into an array
     MergeIntoIndexable::from($obj->{$property}, $value);
 }