Completed
Pull Request — master (#6)
by Alberto
04:09
created

Moka   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 4
dl 0
loc 59
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 4 1
A phpunit() 0 4 1
A prophecy() 0 4 1
A reset() 0 4 1
A clean() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Moka;
5
6
use Moka\Exception\InvalidIdentifierException;
7
use Moka\Exception\MockNotCreatedException;
8
use Moka\Factory\ProxyBuilderFactory;
9
use Moka\Proxy\Proxy;
10
use Moka\Strategy\PHPUnitMockingStrategy;
11
use Moka\Strategy\ProphecyMockingStrategy;
12
13
/**
14
 * Class Moka
15
 * @package Moka
16
 */
17
class Moka
18
{
19
    /**
20
     * @param string $fqcn
21
     * @param string|null $alias
22
     * @return Proxy
23
     *
24
     * @throws MockNotCreatedException
25
     * @throws InvalidIdentifierException
26
     */
27 3
    public static function get(string $fqcn, string $alias = null): Proxy
28
    {
29 3
        return static::phpunit($fqcn, $alias);
30
    }
31
32
    /**
33
     * @param string $fqcn
34
     * @param string|null $alias
35
     * @return Proxy
36
     *
37
     * @throws MockNotCreatedException
38
     * @throws InvalidIdentifierException
39
     */
40 13
    public static function phpunit(string $fqcn, string $alias = null): Proxy
41
    {
42 13
        return ProxyBuilderFactory::get(new PHPUnitMockingStrategy())->getProxy($fqcn, $alias);
43
    }
44
45
    /**
46
     * @param string $fqcn
47
     * @param string|null $alias
48
     * @return Proxy
49
     *
50
     * @throws MockNotCreatedException
51
     * @throws InvalidIdentifierException
52
     */
53 1
    public static function prophecy(string $fqcn, string $alias = null): Proxy
54
    {
55 1
        return ProxyBuilderFactory::get(new ProphecyMockingStrategy())->getProxy($fqcn, $alias);
56
    }
57
58
    /**
59
     * @return void
60
     */
61 14
    public static function reset()
62
    {
63 14
        ProxyBuilderFactory::reset();
64
    }
65
66
    /**
67
     * @return void
68
     *
69
     * @deprecated since 0.3.0
70
     */
71 1
    public static function clean()
72
    {
73 1
        static::reset();
74
    }
75
}
76