getMethodReflectionFromObject()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
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