Passed
Push — master ( 627c19...f3fe5e )
by Armando
03:09
created

Factory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 6
c 4
b 0
f 0
dl 0
loc 15
ccs 5
cts 6
cp 0.8333
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveEntityClass() 0 11 3
1
<?php
2
3
namespace Longman\TelegramBot\Entities;
4
5
abstract class Factory
6
{
7
    abstract public static function make(array $data, string $bot_username): Entity;
8
9 18
    public static function resolveEntityClass(string $class, $property, string $bot_username = ''): Entity
10
    {
11 18
        if (is_a($property, $class)) {
12 2
            return $property;
13
        }
14
15 16
        if (is_subclass_of($class, Factory::class)) {
16
            return $class::make($property, $bot_username);
17
        }
18
19 16
        return new $class($property, $bot_username);
20
    }
21
}
22