Cron   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 25
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 14 2
1
<?php
2
3
namespace BrainExe\Core\DependencyInjection\CompilerPass;
4
5
use BrainExe\Core\Annotations\CompilerPass;
6
use BrainExe\Core\Cron\CronDefinition as CronInterface;
7
use BrainExe\Core\Traits\FileCacheTrait;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
11
/**
12
 * @CompilerPass
13
 */
14
class Cron implements CompilerPassInterface
15
{
16
    use FileCacheTrait;
17
18
    const TAG = 'cron';
19
    const CACHE_FILE = 'crons';
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 1
    public function process(ContainerBuilder $container)
25
    {
26 1
        $allCrons = [];
27
28 1
        $taggedServices = $container->findTaggedServiceIds(self::TAG);
29 1
        foreach (array_keys($taggedServices) as $serviceId) {
30
            /** @var CronInterface $cron */
31 1
            $definition = $container->getDefinition($serviceId);
32 1
            $cron = $definition->getClass();
33 1
            $allCrons = array_merge($allCrons, $cron::getCrons());
34
        }
35
36 1
        $this->dumpVariableToCache(self::CACHE_FILE, $allCrons);
37 1
    }
38
}
39