Code Duplication    Length = 24-24 lines in 2 locations

src/Isolate/LazyObjects/Proxy/Adapter/OcramiusProxyManager/MethodGenerator/GetMethodReplacement.php 1 location

@@ 9-32 (lines=24) @@
6
use ProxyManager\Generator\ParameterGenerator;
7
use Zend\Code\Generator\PropertyGenerator;
8
9
class GetMethodReplacement extends MethodGenerator
10
{
11
    /**
12
     * Constructor
13
     */
14
    public function __construct(PropertyGenerator $methodReplacementsProperty)
15
    {
16
        parent::__construct('getMethodReplacement');
17
        $methodReplacementsProperty  = $methodReplacementsProperty->getName();
18
        $this->setVisibility(self::VISIBILITY_PRIVATE);
19
20
        $this->setParameter(new ParameterGenerator('methodName'));
21
22
        $body =
23
              "foreach (\$this->$methodReplacementsProperty as \$replacementDefinition) {\n"
24
            . "    if (\$replacementDefinition->getMethod()->isEqualTo(\$methodName)) {\n"
25
            . "         return \$replacementDefinition;\n"
26
            . "    }\n"
27
            . "}\n\n"
28
            . "throw new \\RuntimeException(sprintf(\"Method replacement for %s does not exists.\", \$methodName));\n";
29
30
        $this->setBody($body);
31
    }
32
}
33

src/Isolate/LazyObjects/Proxy/Adapter/OcramiusProxyManager/MethodGenerator/HasMethodReplacement.php 1 location

@@ 9-32 (lines=24) @@
6
use ProxyManager\Generator\ParameterGenerator;
7
use Zend\Code\Generator\PropertyGenerator;
8
9
class HasMethodReplacement extends MethodGenerator
10
{
11
    /**
12
     * Constructor
13
     */
14
    public function __construct(PropertyGenerator $methodReplacementsProperty)
15
    {
16
        parent::__construct('hasMethodReplacement');
17
        $methodReplacementsProperty  = $methodReplacementsProperty->getName();
18
        $this->setVisibility(self::VISIBILITY_PRIVATE);
19
20
        $this->setParameter(new ParameterGenerator('methodName'));
21
22
        $body =
23
              "foreach (\$this->$methodReplacementsProperty as \$replacementDefinition) {\n"
24
            . "    if (\$replacementDefinition->getMethod()->isEqualTo(\$methodName)) {\n"
25
            . "         return true;\n"
26
            . "    }\n"
27
            . "}\n\n"
28
            . "return false;\n";
29
30
        $this->setBody($body);
31
    }
32
}
33