CronServiceFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 5
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 16 1
1
<?php
2
3
namespace T4web\Cron\Service;
4
5
use Zend\ServiceManager\ServiceLocatorInterface;
6
use Zend\ServiceManager\FactoryInterface;
7
use Cron\Cron;
8
use T4web\Cron\Resolver\ArrayResolver;
9
use T4web\Cron\Executor\Executor;
10
use T4web\Cron\Config;
11
12
class CronServiceFactory implements FactoryInterface
13
{
14
    /**
15
     * Create service
16
     *
17
     * @param ServiceLocatorInterface $serviceLocator
18
     * @return CronService
19
     */
20
    public function createService(ServiceLocatorInterface $serviceLocator)
21
    {
22
        $config = $serviceLocator->get(Config::class);
23
24
        $resolver = new ArrayResolver($config->getPhpPath(), $config->getScriptPath());
25
        $resolver->buildFromConfig($config->getJobs());
26
27
        $cron = new Cron();
28
        $cron->setResolver($resolver);
29
        $cron->setExecutor(new Executor());
30
31
        return new CronService(
32
            $config->getTimeout(),
33
            $cron
34
        );
35
    }
36
}
37