RemoveDestructorPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 17
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 14 3
1
<?php
2
/**
3
 * Mockery
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the new BSD license that is bundled
8
 * with this package in the file LICENSE.txt.
9
 * It is also available through the world-wide-web at this URL:
10
 * http://github.com/padraic/mockery/blob/master/LICENSE
11
 * If you did not receive a copy of the license and are unable to
12
 * obtain it through the world-wide-web, please send an email
13
 * to [email protected] so we can send you a copy immediately.
14
 *
15
 * @category   Mockery
16
 * @package    Mockery
17
 * @copyright  Copyright (c) 2010 Pádraic Brady (http://blog.astrumfutura.com)
18
 * @license    http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
19
 * @author     Boris Avdeev <[email protected]>
20
 */
21
22
namespace Mockery\Generator\StringManipulation\Pass;
23
24
use Mockery\Generator\MockConfiguration;
25
26
/**
27
 * Remove mock's empty destructor if we tend to use original class destructor
28
 */
29
class RemoveDestructorPass
30
{
31 397
    public function apply($code, MockConfiguration $config)
32
    {
33 397
        $target = $config->getTargetClass();
34
35 397
        if (!$target) {
36 28
            return $code;
37
        }
38
39 373
        if (!$config->isMockOriginalDestructor()) {
40 10
            $code = preg_replace('/public function __destruct\(\)\s+\{.*?\}/sm', '', $code);
41 10
        }
42
43 373
        return $code;
44
    }
45
}
46