LogEntryFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 9 2
1
<?php declare(strict_types=1);
2
3
/**
4
 *  ___             _
5
 * | _ \__ _ _ _ __| |___  __ _
6
 * |  _/ _` | '_(_-< / _ \/ _` |
7
 * |_| \__,_|_| /__/_\___/\__, |
8
 *                        |___/
9
 * 
10
 * (c) Kristuff <[email protected]>
11
 *
12
 * For the full copyright and license information, please view the LICENSE
13
 * file that was distributed with this source code.
14
 *
15
 * @version    0.7.2
16
 * @copyright  2017-2021 Kristuff
17
 */
18
19
namespace Kristuff\Parselog\Core;
20
21
class LogEntryFactory implements LogEntryFactoryInterface
22
{
23
    /**
24
     * Creates and return an object that implements LogEntryInterface with given data
25
     * 
26
     * @access public
27
     * @param array     $data        
28
     * 
29
     * @return \Kristuff\Parselog\Core\LogEntryInterface
30
     */
31
    public function create(array $data): LogEntryInterface
32
    {
33
        $entry = new LogEntry();
34
35
        foreach (array_filter(array_keys($data), 'is_string') as $key) {
36
            $entry->{$key} = trim($data[$key]);
37
        }
38
39
        return $entry;
40
    }
41
42
43
}