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

IgnoreErrorTransportWrapper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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