Completed
Push — master ( 4e528e...b698b3 )
by ARCANEDEV
04:17
created

ConfigHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTableFromConfig() 0 4 1
A getModelFromConfig() 0 4 1
A getFromConfig() 0 4 1
1
<?php namespace Arcanedev\LaravelMessenger\Traits;
2
3
/**
4
 * Trait     ConfigHelper
5
 *
6
 * @package  Arcanedev\LaravelMessenger\Traits
7
 * @author   ARCANEDEV <[email protected]>
8
 */
9
trait ConfigHelper
10
{
11
    /* ------------------------------------------------------------------------------------------------
12
     |  Helper Functions
13
     | ------------------------------------------------------------------------------------------------
14
     */
15
    /**
16
     * Get table from config.
17
     *
18
     * @param  string       $key
19
     * @param  string|null  $default
20
     *
21
     * @return string
22
     */
23
    protected function getTableFromConfig($key, $default = null)
24
    {
25
        return $this->getFromConfig("$key.table", $default);
26
    }
27
28
    /**
29
     * Get model from config.
30
     *
31
     * @param  string       $key
32
     * @param  string|null  $default
33
     *
34
     * @return string
35
     */
36
    protected function getModelFromConfig($key, $default = null)
37
    {
38
        return $this->getFromConfig("$key.model", $default);
39
    }
40
41
    /**
42
     * Get the value from the laravel-messenger config file.
43
     *
44
     * @param  string       $key
45
     * @param  string|null  $default
46
     *
47
     * @return string
48
     */
49
    protected function getFromConfig($key, $default = null)
50
    {
51
        return config("laravel-messenger.$key", $default);
52
    }
53
}
54