Completed
Push — master ( 346425...6beaf7 )
by Jan Philip
05:33
created

FMeatClient::getNextWeekForLocation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
3
namespace JPBernius\FMeat;
4
5
use JPBernius\FMeat\Configurations\Locations;
6
use JPBernius\FMeat\Entities\Week;
7
use JPBernius\FMeat\Services\CachedNetworkService;
8
use JPBernius\FMeat\Services\NetworkService;
9
use JPBernius\FMeat\Utilities\YearWeekUtil;
10
use DI\ContainerBuilder;
11
12
/**
13
 * Class FMeatClient
14
 * @package JPBernius\FMeat
15
 */
16
class FMeatClient
17
{
18
    /** @var NetworkService */
19
    private $networkService;
20
21
    /** @var YearWeekUtil */
22
    private $yearkWeekUtil;
23
24
    /**
25
     * FMeatClient constructor.
26
     * @param bool $useCaching
27
     */
28
    public function __construct(bool $useCaching = false)
29
    {
30
        $container = ContainerBuilder::buildDevContainer();
31
        $this->yearWeekUtil = $container->get(YearWeekUtil::class);
0 ignored issues
show
Bug introduced by
The property yearWeekUtil does not seem to exist. Did you mean yearkWeekUtil?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
32
33
        if ($useCaching) {
34
            $this->networkService = $container->get(CachedNetworkService::class);
35
        } else {
36
            $this->networkService = $container->get(NetworkService::class);
37
        }
38
    }
39
40
    /**
41
     * @param string $location
42
     * @return Week
43
     */
44
    public function getCurrentWeekForLocation(string $location = Locations::FMI_BISTRO): Week
45
    {
46
        $currentWeek = $this->yearWeekUtil->getCurrentCalendarWeek();
0 ignored issues
show
Bug introduced by
The property yearWeekUtil does not seem to exist. Did you mean yearkWeekUtil?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
47
        return $this->networkService->getWeekWithLocation($currentWeek, $location);
48
    }
49
50
    /**
51
     * @param string $location
52
     * @return Week
53
     */
54
    public function getNextWeekForLocation(string $location = Locations::FMI_BISTRO): Week
55
    {
56
        $nextWeek = $this->yearWeekUtil->getNextCalendarWeek();
0 ignored issues
show
Bug introduced by
The property yearWeekUtil does not seem to exist. Did you mean yearkWeekUtil?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
57
        return $this->networkService->getWeekWithLocation($nextWeek, $location);
58
    }
59
}