ReflectionPropertyCapabilities::setProperty()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 3
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php declare(strict_types = 1);
2
3
namespace Simplex\Quickstart\Shared\Testing;
4
5
trait ReflectionPropertyCapabilities
6
{
7
    /**
8
     * @param mixed $object
9
     * @param mixed $propertyValue
10
     */
11
    private function setProperty($object, string $propertyName, $propertyValue): void
12
    {
13
        $refObject = new \ReflectionObject($object);
14
15
        $refProperty = $refObject->getProperty($propertyName);
16
        $refProperty->setAccessible(true);
17
        $refProperty->setValue($object, $propertyValue);
18
    }
19
}
20