Passed
Branch 2.0.0-dev (b7b9ad)
by Jeroen
02:54
created

PhotoFormatter::getContent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace JeroenDesloovere\VCard\Formatter\Property;
4
5
use JeroenDesloovere\VCard\Property\Photo;
6
7
final class PhotoFormatter extends NodeFormatter implements NodeFormatterInterface
8
{
9
    /** @var Photo */
10
    protected $photo;
11
12
    public function __construct(Photo $photo)
13
    {
14
        $this->photo = $photo;
15
    }
16
17
    public function getVcfString(): string
18
    {
19
        $string = Photo::getNode();
20
21
        if ($this->photo->isExternalUrl()) {
0 ignored issues
show
Bug introduced by
The method isExternalUrl() does not exist on JeroenDesloovere\VCard\Property\Photo. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
        if ($this->photo->/** @scrutinizer ignore-call */ isExternalUrl()) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
22
            $string .= ';VALUE=uri';
23
        }
24
25
        if ($this->photo->isInclude()) {
0 ignored issues
show
Bug introduced by
The method isInclude() does not exist on JeroenDesloovere\VCard\Property\Photo. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        if ($this->photo->/** @scrutinizer ignore-call */ isInclude()) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
26
            $string .= ';ENCODING=b';
27
        }
28
29
        $string .= ':' . $this->getContent();
30
31
        return $string;
32
    }
33
34
    private function getContent(): string
35
    {
36
        if ($this->photo->isInclude()) {
37
            return base64_encode($this->photo->getContent());
0 ignored issues
show
Bug introduced by
The method getContent() does not exist on JeroenDesloovere\VCard\Property\Photo. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
            return base64_encode($this->photo->/** @scrutinizer ignore-call */ getContent());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
        }
39
40
        return $this->photo->getContent();
41
    }
42
}
43