Log   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
eloc 10
c 2
b 0
f 0
dl 0
loc 45
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A info() 0 3 1
A error() 0 3 1
A __construct() 0 3 1
A transferLogs() 0 7 4
1
<?php
2
3
namespace neilherbertuk\CelcatWebAPI\Classes;
4
5
use Illuminate\Support\Facades\Log as Logs;
6
class Log
7
{
8
    /**
9
     * @var
10
     */
11
    protected $celcatWebAPI;
12
13
    /**
14
     * Log constructor
15
     * @param $celcatWebAPI
16
     */
17
    public function __construct($celcatWebAPI)
18
    {
19
        $this->celcatWebAPI = $celcatWebAPI;
20
    }
21
22
    /**
23
     * Adds string to logs array
24
     *
25
     * @param  string  $string
26
     * @return void
27
     */
28
    public function info($string)
29
    {
30
        $this->celcatWebAPI->logs[] = ['string' => $string, 'type' => 'info'];
31
    }
32
33
    /**
34
     * Write a string as error output.
35
     *
36
     * @param  string  $string
37
     * @return void
38
     */
39
    public function error($string)
40
    {
41
        $this->celcatWebAPI->logs[] = ['string' => $string, 'type' => 'error'];
42
    }
43
44
    public function transferLogs()
45
    {
46
        foreach ($this->celcatWebAPI->logs as $log) {
47
            if ($log['type'] == "info") {
48
                Logs::info("Celcat Web API: ".$log['string']);
49
            } else if ($log['type'] == "error") {
50
                Logs::error("Celcat Web API: ".$log['string']);
51
            }
52
        }
53
    }
54
55
}