Completed
Pull Request — master (#16)
by Nikola
01:25
created

LoggingAspect   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A beforeMethod() 0 4 1
1
<?php
2
3
namespace Go\Symfony\GoAopBundle\Tests\TestProject\Aspect;
4
5
use Go\Aop\Aspect;
6
use Go\Aop\Intercept\MethodInvocation;
7
use Go\Lang\Annotation\Before;
8
use Psr\Log\LoggerInterface;
9
10
/**
11
 * Application logging aspect
12
 */
13
class LoggingAspect implements Aspect
14
{
15
    /**
16
     * @var LoggerInterface
17
     */
18
    private $logger;
19
20
    public function __construct(LoggerInterface $logger)
21
    {
22
        $this->logger = $logger;
23
    }
24
25
    /**
26
     * Writes a log info before method execution
27
     *
28
     * @param MethodInvocation $invocation
29
     * @Before("@execution(Go\Symfony\GoAopBundle\Tests\TestProject\Annotation\Loggable)")
30
     */
31
    public function beforeMethod(MethodInvocation $invocation)
32
    {
33
        $this->logger->info($invocation, $invocation->getArguments());
34
    }
35
}
36