Completed
Push — next ( 30186a...81988a )
by François
02:27
created

AccessWatchLogger   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 35
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A log() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the Bouncer package.
5
 *
6
 * (c) François Hodierne <[email protected]>
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 Bouncer\Logger;
13
14
use Bouncer\Identity;
15
use Bouncer\Request;
16
17
/**
18
 * Log Connections on the Bouncer Cloud Service
19
 *
20
 * @author François Hodierne <[email protected]>
21
 */
22
class AccessWatchLogger extends LogstashLogger
23
{
24
25
    protected $host = 'access.watch';
26
27
    protected $port = 5145;
28
29
    protected $protocol = 'udp';
30
31
    protected $channel = 'bouncer';
32
33
    protected $type = 'access_log';
34
35
    protected $key;
36
37
    public function __construct($params = [])
38
    {
39
        if (isset($params['apiKey'])) {
40
            $this->key = $params['apiKey'];
41
        }
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47
    public function log($connection, Identity $identity, Request $request)
48
    {
49
        if ($this->key) {
50
            $connection['key'] = $this->key;
51
        }
52
53
        parent::log($connection, $identity, $request);
54
    }
55
56
}
57