Completed
Pull Request — master (#309)
by Luc
08:47
created

ShortDescription::fromCdbXmlToJsonLdFormat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace CultuurNet\UDB3\Cdb\Description;
4
5
use CultuurNet\UDB3\StringFilter\StringFilterInterface;
6
use ValueObjects\StringLiteral\StringLiteral;
7
8 View Code Duplication
class ShortDescription extends StringLiteral
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * @var StringFilterInterface
12
     */
13
    private static $cdbXmlToJsonLdFilter;
14
15
    /**
16
     * @param string $shortDescriptionAsString
17
     * @return ShortDescription
18
     */
19
    public static function fromCdbXmlToJsonLdFormat($shortDescriptionAsString)
20
    {
21
        $cdbXmlToJsonLdFilter = self::getCdbXmlToJsonLdFilter();
22
23
        return new ShortDescription(
24
            $cdbXmlToJsonLdFilter->filter($shortDescriptionAsString)
25
        );
26
    }
27
28
    /**
29
     * @return StringFilterInterface
30
     */
31
    private static function getCdbXmlToJsonLdFilter()
32
    {
33
        if (!isset(self::$cdbXmlToJsonLdFilter)) {
34
            self::$cdbXmlToJsonLdFilter = new CdbXmlShortDescriptionToJsonLdFilter();
35
        }
36
        return self::$cdbXmlToJsonLdFilter;
37
    }
38
}
39