Completed
Push — 0.1 ( 75f716...d81107 )
by Paweł
96:48 queued 48:27
created

AbstractArticleFactory::populateLead()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Web Publisher Content Bundle.
7
 *
8
 * Copyright 2016 Sourcefabric z.ú. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2016 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Bundle\ContentBundle\Factory;
18
19
use SWP\Bundle\ContentBundle\Hydrator\ArticleHydratorInterface;
20
use SWP\Bundle\ContentBundle\Model\ArticleInterface;
21
use SWP\Component\Bridge\Model\PackageInterface;
22
23
abstract class AbstractArticleFactory implements ArticleFactoryInterface
24
{
25
    /**
26
     * @var ArticleHydratorInterface
27
     */
28
    protected $articleHydrator;
29
30
    /**
31
     * AbstractArticleFactory constructor.
32
     *
33
     * @param ArticleHydratorInterface $articleHydrator
34
     */
35 21
    public function __construct(ArticleHydratorInterface $articleHydrator)
36
    {
37 21
        $this->articleHydrator = $articleHydrator;
38 21
    }
39
40
    /**
41
     * @param PackageInterface $package
42
     *
43
     * @return ArticleInterface
44
     */
45 6
    protected function createHydrated(PackageInterface $package)
46
    {
47
        /** @var ArticleInterface $article */
48 6
        $article = $this->create();
49
50 6
        return $this->articleHydrator->hydrate($article, $package);
51
    }
52
}
53