UseCaseServiceProvide   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 4
dl 0
loc 38
rs 10
ccs 17
cts 17
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 18 1
A boot() 0 3 1
1
<?php
2
3
namespace OpenTribes\Core\Silex\Provider;
4
5
6
use OpenTribes\Core\Silex\Repository;
7
use OpenTribes\Core\Silex\Service;
8
use OpenTribes\Core\Silex\UseCase;
9
use OpenTribes\Core\Silex\Validator;
10
use OpenTribes\Core\UseCase\ListDirectionsUseCase;
11
use OpenTribes\Core\UseCase\LoginUseCase;
12
use OpenTribes\Core\UseCase\RegistrationUseCase;
13
use Silex\Application;
14
use Silex\ServiceProviderInterface;
15
16
class UseCaseServiceProvide implements ServiceProviderInterface{
17
    /**
18
     * Registers services on the given app.
19
     *
20
     * This method should only be used to configure services and parameters.
21
     * It should not get services.
22
     */
23 35
    public function register(Application $app)
24
    {
25
        $app[UseCase::LOGIN] = $app->share(function () use ($app) {
26 10
            return new LoginUseCase(
27 10
                $app[Repository::USER],
28 10
                $app[Validator::LOGIN],
29 10
                $app[Service::PASSWORD_HASH]);
30 35
        });
31
        $app[UseCase::REGISTRATION] = $app->share(function () use ($app) {
32 15
            return new RegistrationUseCase(
33 15
                $app[Repository::USER],
34 15
                $app[Validator::REGISTRATION],
35 15
                $app[Service::PASSWORD_HASH]);
36 35
        });
37 35
        $app[UseCase::LIST_DIRECTIONS] = $app->share(function() use($app){
38 4
            return new ListDirectionsUseCase($app[Repository::DIRECTION]);
39 35
        });
40 35
    }
41
42
    /**
43
     * Bootstraps the application.
44
     *
45
     * This method is called after all services are registered
46
     * and should be used for "dynamic" configuration (whenever
47
     * a service must be requested).
48
     */
49 35
    public function boot(Application $app)
50
    {
51 35
    }
52
53
}