Passed
Push — develop ( 1c6380...de24a7 )
by Armando
02:15 queued 14s
created

Factory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 6
c 4
b 0
f 0
dl 0
loc 15
ccs 4
cts 6
cp 0.6667
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 16
    public static function resolveEntityClass(string $class, $property, string $bot_username = ''): Entity
10
    {
11 16
        if (is_a($property, $class)) {
12
            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