Completed
Push — develop ( b85182...537c08 )
by Narcotic
02:54
created

TestUtils   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTestingLogger() 0 7 1
A getFullStringFromLog() 0 10 1
1
<?php
2
/**
3
 * assorted utils for testing
4
 */
5
6
namespace Graviton\ImportExportTest\Util;
7
8
use Monolog\Handler\TestHandler;
9
use Monolog\Logger;
10
11
/**
12
 * @author   List of contributors <https://github.com/libgraviton/import-export/graphs/contributors>
13
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
14
 * @link     http://swisscom.ch
15
 */
16
class TestUtils
17
{
18
19
    /**
20
     * get a logger for testing
21
     *
22
     * @return Logger
23
     */
24
    public static function getTestingLogger()
25
    {
26
        $logger = new Logger("test");
27
        $handler = new TestHandler();
28
        $logger->pushHandler($handler);
29
        return $logger;
30
    }
31
32
    /**
33
     * gets all lines from the handler in one string
34
     *
35
     * @param TestHandler $handler handler
36
     *
37
     * @return string all lines
38
     */
39
    public static function getFullStringFromLog(TestHandler $handler)
40
    {
41
        $entries = array_map(
42
            function ($val) {
43
                return $val['formatted'];
44
            },
45
            $handler->getRecords()
46
        );
47
        return implode(PHP_EOL, $entries);
48
    }
49
}
50