Completed
Push — master ( cfd8f4...8d747d )
by Marcin
01:40
created

Config::logQueries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Mnabialek\LaravelSqlLogger;
4
5
use Illuminate\Contracts\Config\Repository as ConfigRepository;
6
7
class Config
8
{
9
    /**
10
     * @var ConfigRepository
11
     */
12
    protected $repository;
13
14
    /**
15
     * Config constructor.
16
     *
17
     * @param ConfigRepository $repository
18
     */
19
    public function __construct(ConfigRepository $repository)
20
    {
21
        $this->repository = $repository;
22
    }
23
24
    /**
25
     * Whether all queries should be logged.
26
     *
27
     * @return bool
28
     */
29
    public function logQueries()
30
    {
31
        return (bool) $this->repository->get('sql_logger.log_queries');
32
    }
33
34
    /**
35
     * Whether slow queries should be logged.
36
     *
37
     * @return bool
38
     */
39
    public function logSlowQueries()
40
    {
41
        return (bool) $this->repository->get('sql_logger.log_slow_queries');
42
    }
43
44
    /**
45
     * Minimum execution time (in milliseconds) to consider query as slow.
46
     *
47
     * @return float
48
     */
49
    public function slowLogTime()
50
    {
51
        return $this->repository->get('sql_logger.slow_queries_min_exec_time');
52
    }
53
54
    /**
55
     * Whether SQL log should be overridden for each request.
56
     *
57
     * @return bool
58
     */
59
    public function overrideFile()
60
    {
61
        return (bool) $this->repository->get('sql_logger.override_log');
62
    }
63
64
    /**
65
     * Get directory where log files should be saved.
66
     *
67
     * @return string
68
     */
69
    public function logDirectory()
70
    {
71
        return $this->repository->get('sql_logger.directory');
72
    }
73
74
    /**
75
     * Whether query execution time should be converted to seconds.
76
     *
77
     * @return bool
78
     */
79
    public function useSeconds()
80
    {
81
        return (bool) $this->repository->get('sql_logger.convert_to_seconds');
82
    }
83
84
    /**
85
     * Whether console queries should be logged into separate files.
86
     *
87
     * @return bool
88
     */
89
    public function separateConsoleLogs()
90
    {
91
        return (bool) $this->repository->get('sql_logger.log_console_to_separate_file');
92
    }
93
}
94