Completed
Branch master (5a81ac)
by Albert
02:06
created

UpdatesRepository::config()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
namespace Elimuswift\Core\Repositories;
3
4
use Elimuswift\Core\Update;
5
6
/**
7
* Update data repository
8
*/
9
class UpdatesRepository implements Contracts\RepositoryContract
10
{
11
	/**
12
	 * Update Model instance
13
	 *
14
	 * @var mixed
15
	 **/
16
	public $updates;
17
	/**
18
	 * Create a new instance of the UpdatesManager::class
19
	 * 
20
	 **/
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
	 **/
33
	public function releases()
34
	{
35
		return $this->updates->all();
36
	}
37
38
	/**
39
	 * Get a specific update version
40
	 *
41
	 * @return object Elimuswift\Core\Update instance
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
	 * @param string $version Version to compare
54
	 **/
55
	public function laterThan($version)
56
	{
57
		return $this->updates->where('version', '>', $version)->get();
58
	}
59
60
	/**
61
	 * Get the latest update version
62
	 *
63
	 * @return object Elimuswift\Core\Update instance
64
	 * 
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
85
86
}