Twittercard   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateTags() 0 16 2
1
<?php
2
3
namespace SocialLinks\Metas;
4
5
class Twittercard extends MetaBase implements MetaInterface
6
{
7
    const META_NAME_PREFIX = 'twitter:';
8
9
    protected static $characterLimits = array(
10
        'title' => 65,
11
        'description' => 200,
12
    );
13
14
    /**
15
     * {@inheritdoc}
16
     */
17
    protected function generateTags()
18
    {
19
        $this->addMetas($this->page->get(array(
20
            'title',
21
            'text' => 'description',
22
            'twitterUser' => 'site',
23
        )));
24
25
        if ($this->page->getImage()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->page->getImage() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
26
            $this->addMeta('card', 'summary_large_image');
27
            $this->addMeta('image', $this->page->getImage());
28
        } else {
29
            $this->addMeta('card', 'summary');
30
            $this->addMeta('image', $this->page->getIcon());
31
        }
32
    }
33
}
34