Generator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Sugarcrm\UpgradeSpec\Element;
4
5
use Sugarcrm\UpgradeSpec\Formatter\FormatterInterface;
6
use Sugarcrm\UpgradeSpec\Context\Upgrade;
7
8
class Generator
9
{
10
    /**
11
     * @var FormatterInterface
12
     */
13
    private $formatter;
14
15
    /**
16
     * Generator constructor.
17
     *
18
     * @param FormatterInterface $formatter
19
     */
20
    public function __construct(FormatterInterface $formatter)
21
    {
22
        $this->formatter = $formatter;
23
    }
24
25
    /**
26
     * @param ElementInterface $element
27
     * @param Upgrade          $context
28
     *
29
     * @return string
30
     */
31
    public function generate(ElementInterface $element, Upgrade $context)
32
    {
33
        return $this->formatter->asTitle($element->getTitle(), 2)
34
            . $this->formatter->getDelimiter()
35
            . $this->formatter->asBody($element->getBody($context));
36
    }
37
}
38