Passed
Push — quality ( aaf71d...3e536e )
by Arnaud
09:55
created

Vocabulary   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 24
rs 10
c 0
b 0
f 0
ccs 5
cts 5
cp 1
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 10 2
A get() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Cecil.
7
 *
8
 * Copyright (c) Arnaud Ligny <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Cecil\Collection\Taxonomy;
15
16
use Cecil\Collection\Collection as CecilCollection;
17
use Cecil\Collection\CollectionInterface;
18
use Cecil\Collection\ItemInterface;
19
20
/**
21
 * Class Vocabulary.
22
 */
23
class Vocabulary extends CecilCollection implements ItemInterface
24
{
25
    /**
26
     * Adds a term to a Vocabulary collection.
27
     * {@inheritdoc}
28
     */
29 1
    public function add(ItemInterface $item): CollectionInterface
30
    {
31 1
        if ($this->has($item->getId())) {
32
            // return if already exists
33 1
            return $this;
34
        }
35
36 1
        $this->items[] = $item;
37
38 1
        return $this;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function get(string $id): Term
45
    {
46
        return parent::get($id);
47
    }
48
}
49