Completed
Pull Request — master (#14)
by Саша
02:04
created

MessageLoader::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Extraload\Loader;
4
5
use Extraload\Loader\LoaderInterface;
6
7
class MessageLoader extends AutoFlushLoader implements LoaderInterface
8
{
9
    private $loader;
10
11
    public function __construct(LoaderInterface $loader)
12
    {
13
        $this->loader = $loader;
14
    }
15
16
    public function load($data = null)
17
    {
18
        if (!$data instanceof \AMQPEnvelope) {
19
            throw new \InvalidArgumentException('MessageLoader can only load AMQPEnvelope.');
20
        }
21
22
        $this->loader->load(unserialize($data->getBody()));
23
24
        $this->loader->flush();
25
    }
26
}
27