/** * @covers ::intoObject * @dataProvider provideMergeableAssignables */ public function testCanCallIntoObjectStatically($ours, $path, $theirs, $expectedResult) { // ---------------------------------------------------------------- // setup your test // ---------------------------------------------------------------- // perform the change MergeUsingDotNotationPath::intoObject($ours, $path, $theirs); // ---------------------------------------------------------------- // test the results $this->assertEquals($expectedResult, $ours); }
/** * magic method, called when there's an attempt to set a property that * doesn't actually exist * * if $propertyName is a dot.notation.support path, we'll attempt to * set the property using the path * * @param string $propertyName * name of the property to set * @param mixed $propertyValue * value of the property to set * @return void */ public function __set($propertyName, $propertyValue) { // is the user trying to use dot.notation? if (IsDotNotationPath::checkString($propertyName)) { return MergeUsingDotNotationPath::intoObject($this, $propertyName, $propertyValue, DataBag::class); } // if we get here, then we simply have a new property to set // // I hope that it does not recurse! $this->{$propertyName} = $propertyValue; }