Passed
Pull Request — develop (#97)
by BENARD
12:42
created

AddGameOfDayProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 10
c 1
b 0
f 0
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSchedule() 0 13 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VideoGamesRecords\CoreBundle\Scheduler;
6
7
use Symfony\Component\Lock\LockFactory;
8
use Symfony\Component\Lock\Store\SemaphoreStore;
9
use Symfony\Component\Scheduler\Attribute\AsSchedule;
10
use Symfony\Component\Scheduler\RecurringMessage;
11
use Symfony\Component\Scheduler\Schedule;
12
use Symfony\Component\Scheduler\ScheduleProviderInterface;
13
use VideoGamesRecords\CoreBundle\Scheduler\Message\AddGameOfDay;
14
15
#[AsSchedule]
16
class AddGameOfDayProvider implements ScheduleProviderInterface
17
{
18
    public function getSchedule(): Schedule
19
    {
20
        $store = new SemaphoreStore();
21
        $factory = new LockFactory($store);
22
23
        return $this->schedule ??= (new Schedule())
0 ignored issues
show
Bug Best Practice introduced by
The property schedule does not exist on VideoGamesRecords\CoreBu...er\AddGameOfDayProvider. Did you maybe forget to declare it?
Loading history...
24
            ->with(
25
                RecurringMessage::cron(
26
                    '00 12 * * * ',
27
                    new AddGameOfDay()
28
                )
29
            )
30
            ->lock($factory->createLock('add-game-of-day'));
31
    }
32
}
33