Factory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 2
1
<?php
2
/**
3
 * Webino™ (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino for the canonical source repository
6
 * @copyright   Copyright (c) 2015-2017 Webino, s.r.o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoLogLib;
12
13
use WebinoLogLib\Exception;
14
use Zend\Log\Exception\InvalidArgumentException;
15
use Zend\Log\Logger as LoggerEngine;
16
17
/**
18
 * Class Factory
19
 */
20
final class Factory
21
{
22
    /**
23
     * @var LoggerEngine
24
     */
25
    public $loggerEngine;
26
27
    /**
28
     * Create a logger
29
     *
30
     * Set options for a logger. Accepted options are:
31
     * - writers: array of writers to add to this logger
32
     * - exceptionhandler: if true register this logger as exceptionhandler
33
     * - errorhandler: if true register this logger as errorhandler
34
     *
35
     * @param array|\Traversable $options
36
     * @return Logger
37
     * @throws Exception\InvalidArgumentException
38
     */
39
    public function create($options = null)
40
    {
41
        try {
42
            $this->loggerEngine = new LoggerEngine($options);
43
        } catch (InvalidArgumentException $exc) {
44
            throw new Exception\InvalidArgumentException('Unable to create a logger', null, $exc);
45
        }
46
47
        return new Logger(new PsrLogger($this->loggerEngine));
48
    }
49
}
50