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

Moka::reset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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