Passed
Push — master ( 673228...3ba445 )
by yuuki
02:09
created

Writer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 4
dl 0
loc 38
rs 10
ccs 0
cts 19
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A useFluentLogger() 0 15 1
A setPacker() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
10
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
 * THE SOFTWARE.
12
 *
13
 * This software consists of voluntary contributions made by many individuals
14
 * and is licensed under the MIT license.
15
 *
16
 * Copyright (c) 2015-2017 Yuuki Takezawa
17
 *
18
 */
19
20
namespace Ytake\LaravelFluent;
21
22
use Fluent\Logger\FluentLogger;
23
use Fluent\Logger\PackerInterface;
24
use Psr\Log\LoggerInterface;
25
26
/**
27
 * Class Writer
28
 */
29
class Writer extends \Illuminate\Log\Writer
30
{
31
    /** @var null */
32
    protected $packer = null;
33
34
    /**
35
     * @param string      $host
36
     * @param int         $port
37
     * @param array       $options
38
     * @param string|null $tagFormat
39
     * @param string      $level
40
     *
41
     * @return LoggerInterface
42
     */
43
    public function useFluentLogger(
44
        string $host,
45
        int $port,
46
        array $options = [],
47
        string $tagFormat = null,
48
        string $level = 'debug'
49
    ): LoggerInterface {
50
        return $this->monolog->pushHandler(
51
            new FluentHandler(
52
                new FluentLogger($host, $port, $options, $this->packer),
53
                $tagFormat,
54
                $this->parseLevel($level)
55
            )
56
        );
57
    }
58
59
    /**
60
     * @param PackerInterface $packer
61
     */
62
    public function setPacker(PackerInterface $packer)
63
    {
64
        $this->packer = $packer;
0 ignored issues
show
Documentation Bug introduced by
It seems like $packer of type object<Fluent\Logger\PackerInterface> is incompatible with the declared type null of property $packer.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
65
    }
66
}
67