AnnotationLineConfigurator::configureFrom()   C
last analyzed

Complexity

Conditions 9
Paths 256

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
nc 256
nop 1
dl 0
loc 29
rs 6.5222
c 0
b 0
f 0
1
<?php
2
3
namespace MyBuilder\Bundle\CronosBundle\Exporter;
4
5
use MyBuilder\Bundle\CronosBundle\Annotation\Cron as CronAnnotation;
6
use MyBuilder\Cronos\Formatter\Job;
7
8
class AnnotationLineConfigurator
9
{
10
    /** @var Job */
11
    private $line;
12
13
    public function __construct(Job $line)
14
    {
15
        $this->line = $line;
16
    }
17
18
    public function configureFrom(CronAnnotation $annotation): Job
19
    {
20
        if ($annotation->minute !== null) {
21
            $this->line->setMinute($annotation->minute);
22
        }
23
        if ($annotation->hour !== null) {
24
            $this->line->setHour($annotation->hour);
25
        }
26
        if ($annotation->dayOfMonth !== null) {
27
            $this->line->setDayOfMonth($annotation->dayOfMonth);
28
        }
29
        if ($annotation->month !== null) {
30
            $this->line->setMonth($annotation->month);
31
        }
32
        if ($annotation->dayOfWeek !== null) {
33
            $this->line->setDayOfWeek($annotation->dayOfWeek);
34
        }
35
        if ($annotation->logFile !== null) {
36
            $this->line->setStandardOutFile($annotation->logFile);
37
        }
38
        if ($annotation->errorFile !== null) {
39
            $this->line->setStandardErrorFile($annotation->errorFile);
40
        }
41
        if ($annotation->noLogs !== null) {
42
            $this->line->suppressOutput();
43
        }
44
45
        return $this->line;
46
    }
47
}
48