Completed
Pull Request — master (#47)
by ARCANEDEV
06:27
created

MetaCollection::addOne()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 2
dl 0
loc 10
ccs 5
cts 5
cp 1
crap 3
rs 9.9332
c 0
b 0
f 0
1
<?php namespace Arcanedev\SeoHelper\Entities;
2
3
use Arcanedev\SeoHelper\Bases\MetaCollection as BaseMetaCollection;
4
use Arcanedev\SeoHelper\Helpers\Meta;
5
6
/**
7
 * Class     MetaCollection
8
 *
9
 * @package  Arcanedev\SeoHelper\Bases
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class MetaCollection extends BaseMetaCollection
13
{
14
    /* -----------------------------------------------------------------
15
     |  Properties
16
     | -----------------------------------------------------------------
17
     */
18
19
    /**
20
     * Ignored tags, they have dedicated class.
21
     *
22
     * @var array
23
     */
24
    protected $ignored = [
25
        'description',
26
        'keywords'
27
    ];
28
29
    /* -----------------------------------------------------------------
30
     |  Main Methods
31
     | -----------------------------------------------------------------
32
     */
33
34
    /**
35
     * Add a meta to collection.
36
     *
37
     * @param  string  $name
38
     * @param  string  $content
39
     *
40
     * @return \Arcanedev\SeoHelper\Entities\MetaCollection
41
     */
42 184
    public function addOne($name, $content)
43
    {
44 184
        $meta = Meta::make($name, $content);
45
46 184
        if ($meta->isValid() && ! $this->isIgnored($name)) {
47 184
            $this->put($meta->key(), $meta);
48
        }
49
50 184
        return $this;
51
    }
52
}
53