UpdatesRepository::__construct()   A
last analyzed

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 1
1
<?php
2
3
namespace Elimuswift\Core\Repositories;
4
5
use Elimuswift\Core\Update;
6
7
/**
8
 * Update data repository.
9
 */
10
class UpdatesRepository implements Contracts\RepositoryContract
11
{
12
    /**
13
     * Update Model instance.
14
     *
15
     * @var mixed
16
     **/
17
    public $updates;
18
19
    /**
20
     * Create a new instance of the UpdatesManager::class.
21
     **/
22
    public function __construct(Update $update)
23
    {
24
        $this->updates = $update;
25
    }
26
27
    /**
28
     * Return all the available releses.
29
     *
30
     * @return mixed Illuminate\Support\Collection
31
     **/
32
    public function releases()
33
    {
34
        return $this->updates->all();
35
    }
36
37
    /**
38
     * Get a specific update version.
39
     *
40
     * @return object Elimuswift\Core\Update instance
41
     *
42
     * @param string $version Build version
43
     **/
44
    public function getRelease($version)
45
    {
46
        return $this->updates->whereVersion($version)->first();
47
    }
48
49
    /**
50
     * Get releases later than the provided $version.
51
     *
52
     * @return object Illuminate\Support\Collection
53
     *
54
     * @param string $version Version to compare
55
     **/
56
    public function laterThan($version)
57
    {
58
        return $this->updates->where('version', '>', $version)->get();
59
    }
60
61
    /**
62
     * Get the latest update version.
63
     *
64
     * @return object Elimuswift\Core\Update instance
65
     **/
66
    public function latest()
67
    {
68
        return $this->updates->orderBy('version', 'DESC')->first();
69
    }
70
71
    /**
72
     * Get config properties.
73
     *
74
     * @return mixed
75
     **/
76
    public function config($property)
77
    {
78
        if (config()->has("core.{$property}")) {
79
            return config()->get("core.{$property}");
80
        }
81
        throw new \Exception("Property {$property} does not exist", 1);
82
    }
83
}
84