Skip to content

Commit 65d297c

Browse files
Adding Configurable Trait
1 parent 5d4a969 commit 65d297c

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

src/Traits/Configurable.php

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php namespace Arcanedev\Support\Traits;
2+
3+
/**
4+
* Class Configurable
5+
*
6+
* @package Arcanedev\Support\Traits
7+
* @author ARCANEDEV <arcanedev.maroc@gmail.com>
8+
*/
9+
trait Configurable
10+
{
11+
/* ------------------------------------------------------------------------------------------------
12+
| Properties
13+
| ------------------------------------------------------------------------------------------------
14+
*/
15+
/**
16+
* Config items.
17+
*
18+
* @var array
19+
*/
20+
protected $configs = [];
21+
22+
/* ------------------------------------------------------------------------------------------------
23+
| Getters & Setters
24+
| ------------------------------------------------------------------------------------------------
25+
*/
26+
/**
27+
* Set the config array.
28+
*
29+
* @param array $configs
30+
*
31+
* @return self
32+
*/
33+
protected function setConfigs(array $configs)
34+
{
35+
$this->configs = $configs;
36+
37+
return $this;
38+
}
39+
40+
/**
41+
* Get a config item.
42+
*
43+
* @param string $key
44+
* @param mixed|null $default
45+
*
46+
* @return mixed
47+
*/
48+
protected function getConfig($key, $default = null)
49+
{
50+
return array_get($this->configs, $key, $default);
51+
}
52+
}

0 commit comments

Comments
 (0)