PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.41
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.41
2.1.0 2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 All 42 releases
fluent-boards / vendor / wpfluent / framework / src / WPFluent / Foundation / Config.php

Config.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.41, at vendor/wpfluent/framework/src/WPFluent/Foundation/Config.php

93 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBoards\Framework\Foundation;
4
5 use FluentBoards\Framework\Support\Arr;
6
7 class Config
8 {
9 /**
10 * The config data
11 * @var array
12 */
13 protected $data = [];
14
15 /**
16 * Construct the Config instance
17 * @param null
18 */
19 public function __construct($data)
20 {
21 $this->data = $data;
22 }
23
24 /**
25 * Retrieve all config data
26 * @return array
27 */
28 public function all()
29 {
30 return $this->get();
31 }
32
33 /**
34 * Retrieve specific item from config array.
35 *
36 * @param string $key
37 * @param string $default
38 * @return mixed
39 */
40 public function get($key = null, $default = null)
41 {
42 $key = $this->resolveKey($key);
43
44 return $key ? Arr::get($this->data, $key, $default) : $this->data;
45 }
46
47 /**
48 * Get only specific items from the config array.
49 *
50 * @param string|array $key ($key1, $key2 or [$key1, $key2])
51 * @return array
52 */
53 public function only($key)
54 {
55 $keys = array_map(function ($key) {
56 return $this->resolveKey($key);
57 }, is_Array($key) ? $key : func_get_args());
58
59 $result = [];
60
61 foreach ($keys as $key) {
62 $result[] = Arr::get($this->data, $key);
63 }
64
65 return array_values(array_filter($result));
66 }
67
68 /**
69 * Set an item into the config array on the fly.
70 * @param string $key
71 * @param mkixed $value
72 */
73 public function set($key, $value)
74 {
75 Arr::set($this->data, $key, $value);
76 }
77
78 /**
79 * Resolove the config key, add app. prefix if needed.
80 *
81 * @param string $key
82 * @return string
83 */
84 protected function resolveKey($key)
85 {
86 if (array_key_exists($key, $this->data)) {
87 return $key;
88 }
89
90 return str_contains($key, '.') ? $key : "app.{$key}";
91 }
92 }
93