Completed
Push — master ( 79c13f...0bf349 )
by Ariel
03:04
created

VacancyTemplateBuilder::addTimeRangeStatement()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Timegridio\Concierge\Vacancy;
4
5
use Timegridio\Concierge\Models\Business;
6
use Timegridio\Concierge\Models\Service;
7
8
class VacancyTemplateBuilder
9
{
10
    protected $statement = [];
11
12
    public function getTemplate(Business $business, Service $service)
13
    {
14
        $this->addServiceStatement($service);
15
        $this->addDaysStatement();
16
        $this->addTimeRangeStatement($business->pref('start_at'), $business->pref('finish_at'));
17
18
        return $this->build();
19
    }
20
21
    protected function addServiceStatement(Service $service)
22
    {
23
        $this->addStatement($service->slug.':1');
0 ignored issues
show
Documentation introduced by
The property slug does not exist on object<Timegridio\Concierge\Models\Service>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
24
    }
25
26
    protected function addDaysStatement()
27
    {
28
        $this->addStatement(' mon, tue, wed, thu, fri, sat');
29
    }
30
31
    protected function addTimeRangeStatement($startAt, $finishAt)
32
    {
33
        $this->addStatement('  '.$startAt.' - '.$finishAt);
34
    }
35
36
    protected function addStatement($statement)
37
    {
38
        $this->statement[] = $statement;
39
    }
40
41
    protected function build()
42
    {
43
        return implode("\n", $this->statement);
44
    }
45
}
46