Completed
Push — master ( ee4eef...e76f94 )
by Mahmoud
22:54
created

FindSettingsService   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A byKey() 0 6 1
A getReferringUserPoints() 0 4 1
A getReferredUserPoints() 0 4 1
1
<?php
2
3
namespace App\Containers\Settings\Services;
4
5
use App\Containers\Settings\Settings\Repositories\SettingsRepository;
6
use App\Port\Service\Abstracts\Service;
7
8
/**
9
 * Class FindSettingsService
10
 *
11
 * @author  Mahmoud Zalt  <[email protected]>
12
 */
13
class FindSettingsService extends Service
14
{
15
16
    /**
17
     * @var  \App\Containers\Settings\Settings\Repositories\SettingsRepository
18
     */
19
    private $settingsRepository;
20
21
    /**
22
     * FindSettingsService constructor.
23
     *
24
     * @param \App\Containers\Settings\Settings\Repositories\SettingsRepository $settingsRepository
25
     */
26
    public function __construct(SettingsRepository $settingsRepository)
27
    {
28
        $this->settingsRepository = $settingsRepository;
29
    }
30
31
    /**
32
     * @param $id
33
     *
34
     * @return  mixed
35
     */
36
    public function byKey($key)
37
    {
38
        $result = $this->settingsRepository->findWhere(['key' => $key])->first();
39
40
        return $result->value;
41
    }
42
43
    /**
44
     * @return  mixed
45
     */
46
    public function getReferringUserPoints()
47
    {
48
        return $this->byKey('referring_user_points');
49
    }
50
51
    /**
52
     * @return  mixed
53
     */
54
    public function getReferredUserPoints()
55
    {
56
        return $this->byKey('referred_user_points');
57
    }
58
59
}
60