getMethod($methodName); $method->setAccessible(true); return $method->invokeArgs($object, $arguments); } /** * Sets a private or protected property in defined class instance * * @param object $object * @param string $valueName * @param $value * @throws ReflectionException */ public function setValue(object $object, string $valueName, $value) { $reflection = new ReflectionClass($object); $property = $reflection->getProperty($valueName); $property->setAccessible(true); $property->setValue($object, $value); } /** * get a private or protected property from defined class instance * * @param object $object * @param string $valueName * @return mixed * @throws ReflectionException */ public function getValue(object $object, string $valueName) { $reflection = new ReflectionClass($object); $property = $reflection->getProperty($valueName); $property->setAccessible(true); return $property->getValue($object); } }