Code Duplication    Length = 20-20 lines in 2 locations

src/AspectRegister.php 2 locations

@@ 72-91 (lines=20) @@
69
     *
70
     * @return array<\AppserverIo\Doppelgaenger\Entities\Definitions\Advice>
71
     */
72
    public function lookupAdvice($adviceExpression)
73
    {
74
        // clean the expression
75
        $adviceExpression = trim(ltrim(rtrim($adviceExpression, '()'), '\\'));
76
77
        // if there is an aspect name within the expression we have to filter our search range and cut the expression
78
        $container = $this->container;
79
        if (strpos($adviceExpression, '->')) {
80
            $aspectExpression = strstr($adviceExpression, '->', true);
81
            $container = $this->lookupAspects($aspectExpression);
82
            $adviceExpression = str_replace('->', '', strstr($adviceExpression, '->'));
83
        }
84
85
        $matches = array();
86
        foreach ($container as $aspect) {
87
            $matches = array_merge($matches, $this->lookupEntries($aspect->getAdvices(), $adviceExpression));
88
        }
89
90
        return $matches;
91
    }
92
93
    /**
94
     * Will narrow down the choice of aspects to make when looking up pointcuts or advices.
@@ 143-162 (lines=20) @@
140
     *
141
     * @return array<\AppserverIo\Doppelgaenger\Entities\Definitions\Pointcut>
142
     */
143
    public function lookupPointcuts($pointcutExpression)
144
    {
145
        // clean the expression
146
        $pointcutExpression = trim(ltrim(rtrim($pointcutExpression, '()'), '\\'));
147
148
        // if there is an aspect name within the expression we have to filter our search range and cut the expression
149
        $container = $this->container;
150
        if (strpos($pointcutExpression, '->')) {
151
            $aspectExpression = strstr($pointcutExpression, '->', true);
152
            $container = $this->lookupAspects($aspectExpression);
153
            $pointcutExpression = str_replace('->', '', strstr($pointcutExpression, '->'));
154
        }
155
156
        $matches = array();
157
        foreach ($container as $aspect) {
158
            $matches = array_merge($matches, $this->lookupEntries($aspect->getPointcuts(), $pointcutExpression));
159
        }
160
161
        return $matches;
162
    }
163
164
    /**
165
     * Will register a complete aspect to the AspectRegister.