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

IgnoreErrorTransportWrapper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 34
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A send() 0 8 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