Completed
Push — master ( 401ef4...2832e5 )
by yuuki
02:02
created

LazyMessage   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 13 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-2017 Yuuki Takezawa
16
 *
17
 */
18
19
namespace Ytake\LaravelAspect\Queue;
20
21
use Ray\Aop\MethodInvocation;
22
use Illuminate\Bus\Queueable;
23
use Illuminate\Container\Container;
24
use Illuminate\Queue\SerializesModels;
25
use Illuminate\Queue\InteractsWithQueue;
26
use Illuminate\Contracts\Queue\ShouldQueue;
27
28
/**
29
 * Class LazyMessage
30
 */
31
class LazyMessage implements ShouldQueue
32
{
33
    use InteractsWithQueue, Queueable, SerializesModels;
34
35
    /** @var MethodInvocation */
36
    protected $methodInvocation;
37
38
    /**
39
     * LazyMessage constructor.
40
     *
41
     * @param MethodInvocation $invocation
42
     */
43
    public function __construct(MethodInvocation $invocation)
44
    {
45
        $this->methodInvocation = $invocation;
46
    }
47
48
    /**
49
     * @param Container $container
50
     */
51
    public function handle(Container $container)
52
    {
53
        $class = new \ReflectionClass(get_class($this->methodInvocation->getThis()));
54
        require_once $class->getFileName();
55
        $method = $this->methodInvocation->getMethod()->getName();
0 ignored issues
show
Bug introduced by
Consider using $this->methodInvocation->getMethod()->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
56
        $container->call(
57
            [
58
                $this->methodInvocation->getThis(),
59
                $method,
60
            ],
61
            $this->methodInvocation->getArguments()->getArrayCopy()
62
        );
63
    }
64
}
65