Completed
Push — master ( d4d7bc...0f591f )
by yuuki
03:49 queued 01:43
created

AsyncPointCut::withAnnotatedAnyInterceptor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
/**
4
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
7
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
8
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
9
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
10
 * THE SOFTWARE.
11
 *
12
 * This software consists of voluntary contributions made by many individuals
13
 * and is licensed under the MIT license.
14
 *
15
 * Copyright (c) 2015-2016 Yuuki Takezawa
16
 *
17
 */
18
namespace Ytake\LaravelAspect\PointCut;
19
20
use Ray\Aop\Matcher;
21
use Ray\Aop\Pointcut;
22
use Illuminate\Contracts\Container\Container;
23
use Ytake\LaravelAspect\Annotation\Async;
24
use Ytake\LaravelAspect\Interceptor\AsyncInterceptor;
25
26
/**
27
 * Class AsyncPointCut
28
 */
29
class AsyncPointCut extends CommonPointCut implements PointCutable
30
{
31
    /** @var string */
32
    protected $annotation = Async::class;
33
34
    /**
35
     * @param Container $app
36
     *
37
     * @return \Ray\Aop\Pointcut
38
     */
39
    public function configure(Container $app)
40
    {
41
        $this->setInterceptor(new AsyncInterceptor);
42
43
        return $this->withAnnotatedAnyInterceptor($app);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    protected function withAnnotatedAnyInterceptor(Container $app)
50
    {
51
        return new Pointcut(
52
            (new Matcher)->any(),
53
            (new Matcher)->annotatedWith($this->annotation),
54
            [$this->interceptor]
55
        );
56
    }
57
}
58