Completed
Push — develop ( be2302...866404 )
by Martin
05:00
created

TagBuilder   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 23
ccs 14
cts 14
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B buildTags() 0 20 5
1
<?php
2
/**
3
 * Yii2 AR Tag Cache.
4
 *
5
 * This file contains helper class for tag building.
6
 *
7
 * @author  Aleksei Korotin <[email protected]>
8
 */
9
namespace herroffizier\yii2artc;
10
11
use yii\base\InvalidConfigException;
12
13
class TagBuilder
14
{
15 24
    public static function buildTags($classes)
16
    {
17 24
        if (!is_array($classes)) {
18 9
            $classes = [$classes];
19 6
        }
20
21 24
        $tags = [];
22
23 24
        foreach ($classes as $class) {
24 24
            if (is_string($class)) {
25 9
                $tags[] = $class;
26 21
            } elseif (is_object($class)) {
27 12
                $tags[] = $class::className();
28 8
            } else {
29 10
                throw new InvalidConfigException('Cannot build tags from anything other than objects or class names');
30
            }
31 14
        }
32
33 21
        return $tags;
34
    }
35
}
36