2020-12-11 01:25:38 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Toalett\Multiprocessing\Tests\Tools;
|
|
|
|
|
|
|
|
use ReflectionObject;
|
|
|
|
|
|
|
|
trait PropertyInspector
|
|
|
|
{
|
|
|
|
protected function getProperty(object $object, string $propertyName)
|
|
|
|
{
|
|
|
|
$reflector = new ReflectionObject($object);
|
|
|
|
$property = $reflector->getProperty($propertyName);
|
|
|
|
$property->setAccessible(true);
|
|
|
|
return $property->getValue($object);
|
|
|
|
}
|
2020-12-12 02:11:05 +01:00
|
|
|
|
|
|
|
protected function setProperty(object $object, string $propertyName, $value): void
|
|
|
|
{
|
|
|
|
$reflector = new ReflectionObject($object);
|
|
|
|
$property = $reflector->getProperty($propertyName);
|
|
|
|
$property->setAccessible(true);
|
|
|
|
$property->setValue($object, $value);
|
|
|
|
}
|
2020-12-11 01:25:38 +01:00
|
|
|
}
|