Test Setup Failed
Push — master ( a515d0...24a3ce )
by Raí
07:35 queued 02:54
created

bind_contract_repository()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
3
/*
4
 * Default binding a repository interface to a concret class
5
 */
6
if (!function_exists('bind_contract_repository')) {
7
    function bind_contract_repository(string $repositoryInterface, string $repository, string $entity)
8
    {
9
        app()->bind($repositoryInterface, function ($app) use ($repository, $entity) {
10
            return new $repository(
11
                $app['em'],
12
                $app['em']->getClassMetaData($entity)
13
            );
14
        });
15
    }
16
}
17
18
if (!function_exists('bdEntityName')) {
19
    /**
20
     * @param string $className
21
     */
22
    function bdEntityName(string $className)
23
    {
24
        return config('bludata.generator.rootNamespace').'Entities\\'.$className;
25
    }
26
}
27
28
if (!function_exists('bdEntity')) {
29
    /**
30
     * @param string $className
31
     */
32
    function bdEntity(string $className)
33
    {
34
        return app(bdEntityName($className));
35
    }
36
}
37
38
if (!function_exists('bdContractName')) {
39
    /**
40
     * @param string $className
41
     */
42
    function bdContractName(string $className)
43
    {
44
        return config('bludata.generator.rootNamespace').'Contracts\Repositories\\'.$className.'RepositoryContract';
45
    }
46
}
47
48
if (!function_exists('bdRepositoryName')) {
49
    /**
50
     * @param string $className
51
     */
52
    function bdRepositoryName(string $className)
53
    {
54
        return config('bludata.generator.rootNamespace').'Repositories\\'.$className.'Repository';
55
    }
56
}
57
58
if (!function_exists('bdRepository')) {
59
    /**
60
     * @param string $className
61
     */
62
    function bdRepository(string $className)
63
    {
64
        return app(bdContractName($className));
65
    }
66
}
67