| Total Complexity | 4 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | final class AuraSqlConnectionInterceptor implements MethodInterceptor |
||
| 18 | { |
||
| 19 | public const PROP = 'pdo'; |
||
| 20 | |||
| 21 | /** @phpstan-param array<string> $readsMethods */ |
||
| 22 | public function __construct( |
||
| 23 | private ConnectionLocatorInterface $connectionLocator, |
||
| 24 | /** @var string[] */ |
||
| 25 | #[Read] |
||
| 26 | private array $readsMethods |
||
| 27 | ) { |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * {@inheritDoc} |
||
| 32 | */ |
||
| 33 | #[Override] |
||
| 34 | public function invoke(MethodInvocation $invocation) |
||
| 35 | { |
||
| 36 | $connection = $this->getConnection($invocation); |
||
| 37 | $object = $invocation->getThis(); |
||
| 38 | $ref = new ReflectionProperty($object, self::PROP); |
||
| 39 | 3 | $ref->setValue($object, $connection); |
|
| 40 | |||
| 41 | 3 | return $invocation->proceed(); |
|
| 42 | 3 | } |
|
| 43 | 3 | ||
| 44 | 3 | /** @param MethodInvocation<object> $invocation */ |
|
| 45 | private function getConnection(MethodInvocation $invocation): ExtendedPdoInterface |
||
| 53 | 1 | } |
|
| 54 | } |
||
| 55 |