Passed
Push — master ( 46729e...9da378 )
by Benjamin
05:02 queued 03:07
created

AbstractTransport::setMessageEncoder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
/*
4
 * This file is part of the php-gelf package.
5
 *
6
 * (c) Benjamin Zikarsky <http://benjamin-zikarsky.de>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Gelf\Transport;
13
14
use Gelf\Encoder\EncoderInterface;
15
use Gelf\MessageInterface;
16
use Gelf\PublisherInterface;
17
18
/**
19
 * The CompressedJsonEncoder allows the encoding of GELF messages as described
20
 * in http://www.graylog2.org/resources/documentation/sending/gelfhttp
21
 *
22
 * @author Benjamin Zikarsky <[email protected]>
23
 */
24
abstract class AbstractTransport implements TransportInterface, PublisherInterface
25
{
26
27
    /**
28
     * @var EncoderInterface
29
     */
30
    protected $messageEncoder;
31
32
    /**
33
     * Sets a message encoder
34
     *
35
     * @param EncoderInterface $encoder
36
     *
37
     * @return $this
38
     */
39 29
    public function setMessageEncoder(EncoderInterface $encoder)
40
    {
41 29
        $this->messageEncoder = $encoder;
42
43 29
        return $this;
44
    }
45
46
    /**
47
     * Returns the current message encoder
48
     *
49
     * @return EncoderInterface
50
     */
51 17
    public function getMessageEncoder()
52
    {
53 17
        return $this->messageEncoder;
54
    }
55
56
    /**
57
     * Alias to send() without return value
58
     * Required to fulfill the PublisherInterface
59
     *
60
     * @deprecated deprecated since 1.1
61
     * @codeCoverageIgnore
62
     *
63
     * @param MessageInterface $message
64
     *
65
     * @return int the number of bytes sent
66
     */
67
    public function publish(MessageInterface $message)
68
    {
69
        return $this->send($message);
70
    }
71
}
72