Completed
Pull Request — master (#60)
by
unknown
02:28
created

IgnoreErrorTransportWrapper::send()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Gelf\Transport;
4
5
use Gelf\MessageInterface as Message;
6
7
/**
8
 * A wrapper for any AbstractTransport to ignore any kind of errors
9
 * @package Gelf\Transport
10
 */
11
class IgnoreErrorTransportWrapper extends AbstractTransport
12
{
13
14
    /**
15
     * @var AbstractTransport
16
     */
17
    private $transport;
18
19
    /**
20
     * IgnoreErrorTransportWrapper constructor.
21
     *
22
     * @param AbstractTransport $transport
23
     */
24 1
    public function __construct(AbstractTransport $transport)
25
    {
26 1
        $this->transport = $transport;
27 1
    }
28
29
    /**
30
     * Sends a Message over this transport.
31
     *
32
     * @param Message $message
33
     *
34
     * @return int the number of bytes sent
35
     */
36 1
    public function send(Message $message)
37
    {
38
        try {
39 1
            return $this->transport->send($message);
40 1
        } catch (\Exception $e) {
41 1
            return 0;
42
        }
43
    }
44
}
45