Opengraph   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 35
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateTags() 0 21 2
1
<?php
2
3
namespace SocialLinks\Metas;
4
5
class Opengraph extends MetaBase implements MetaInterface
6
{
7
    const META_ATTRIBUTE_NAME = 'property';
8
    const META_NAME_PREFIX = 'og:';
9
10
    protected static $characterLimits = array(
11
        'title' => 65,
12
        'description' => 156,
13
    );
14
15
    /**
16
     * {@inheritdoc}
17
     */
18
    protected function generateTags()
19
    {
20
        $this->addMeta('type', 'website');
21
22
        $this->addMetas($this->page->get(array(
23
            'title',
24
            'url',
25
            'text' => 'description',
26
        )));
27
28
        $images = array_filter($this->page->get(array(
29
            'image',
30
            'icon'
31
        )));
32
33
        if (count($images) === 1) {
34
            $this->addMeta('image', array_shift($images));
35
        } else {
36
            $this->addMeta('image', $images);
37
        }
38
    }
39
}
40