ReflectionProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMethodReflectionFromClassString() 0 6 2
A getMethodReflectionFromObject() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Pgs\HashIdBundle\Reflection;
6
7
use Pgs\HashIdBundle\Exception\MissingClassOrMethodException;
8
use ReflectionException;
9
use ReflectionMethod;
10
11
class ReflectionProvider
12
{
13 3
    public function getMethodReflectionFromClassString(string $class, string $method): ?ReflectionMethod
14
    {
15
        try {
16 3
            return new ReflectionMethod($class, $method);
17 1
        } catch (ReflectionException $e) {
18 1
            throw new MissingClassOrMethodException($e->getMessage(), $e->getCode(), $e);
19
        }
20
    }
21
22
    /**
23
     * @param mixed $object
24
     */
25 2
    public function getMethodReflectionFromObject($object, string $method): ?ReflectionMethod
26
    {
27
        try {
28 2
            return new ReflectionMethod($object, $method);
29 1
        } catch (ReflectionException $e) {
30 1
            throw new MissingClassOrMethodException($e->getMessage(), $e->getCode(), $e);
31
        }
32
    }
33
}
34