PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 2.1.0
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v2.1.0
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
← All changes | vendor/wpfluent/framework/src/WPFluent/Foundation/Config.php +44 -3 1.212.1.0 View file →
@@ -13,9 +13,9 @@
13 13 protected $data = [];
14 14
15 15 /**
16 16 * Construct the Config instance
17 - * @param null
17 + * @param array $data
18 18 */
19 19 public function __construct($data)
20 20 {
21 21 $this->data = $data;
@@ -30,9 +30,10 @@
30 30 return $this->get();
31 31 }
32 32
33 33 /**
34 - * Retrieve specific item from config array
34 + * Retrieve specific item from config array.
35 + *
35 36 * @param string $key
36 37 * @param string $default
37 38 * @return mixed
38 39 */
@@ -37,17 +38,57 @@
37 38 * @return mixed
38 39 */
39 40 public function get($key = null, $default = null)
40 41 {
42 + $key = $this->resolveKey($key);
43 +
41 44 return $key ? Arr::get($this->data, $key, $default) : $this->data;
42 45 }
43 46
44 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 + /**
45 69 * Set an item into the config array on the fly.
46 70 * @param string $key
47 - * @param mkixed $value
71 + * @param mixed $value
48 72 */
49 73 public function set($key, $value)
50 74 {
51 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 (!$key) return $key;
87 +
88 + if (array_key_exists($key, $this->data)) {
89 + return $key;
90 + }
91 +
92 + return str_contains($key, '.') ? $key : "app.{$key}";
52 93 }
53 94 }