Completed
Push — master ( 3f65c6...83b473 )
by Vincent
02:48
created

InterceptedClass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 36
rs 10
1
<?php
2
3
/**
4
 * Copyright 2016 Inneair
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 *
18
 * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache-2.0
19
 */
20
21
namespace Inneair\TransactionBundle\Test\Aop\Fixture;
22
23
use Closure;
24
use ReflectionClass;
25
use Inneair\TransactionBundle\Aop\TransactionalInterceptor;
26
27
/**
28
 * A class intercepted by the {@link TransactionalInterceptor}.
29
 */
30
class InterceptedClass
31
{
32
    /**
33
     * A method returing a value.
34
     *
35
     * @return null Null value.
36
     */
37
    public function aMethod()
38
    {
39
        return null;
40
    }
41
42
    /**
43
     * A method throwing an exception.
44
     *
45
     * @param string $exceptionClass Exception class to be thrown.
46
     * @throws Exception The thrown exception.
47
     */
48
    public function bMethodThrowException($exceptionClass)
49
    {
50
        $reflectedException = new ReflectionClass($exceptionClass);
51
        throw $reflectedException->newInstance();
52
    }
53
54
    /**
55
     * A method returning the result of another method (to check nested transactions).
56
     *
57
     * @param Closure $nestedCallback Nested [@link TransactionalInterceptor::intercept} call.
58
     * @param array $parameters Parameters for the nested call.
59
     * @return null Null value.
60
     */
61
    public function cMethod(Closure $nestedCallback, array $parameters = null)
62
    {
63
        return call_user_func_array($nestedCallback, $parameters);
64
    }
65
}
66