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

AccessWatchLogger::getKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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