PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.4.2
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.4.2
4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.5.2 All 199 releases
betterdocs / includes / Dependencies / DI / Definition / ArrayDefinition.php

ArrayDefinition.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 3.4.2, at includes/Dependencies/DI/Definition/ArrayDefinition.php

74 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WPDeveloper\BetterDocs\Dependencies\DI\Definition;
6
7 /**
8 * Definition of an array containing values or references.
9 *
10 * @since 5.0
11 * @author Matthieu Napoli <matthieu@mnapoli.fr>
12 */
13 class ArrayDefinition implements Definition
14 {
15 /**
16 * Entry name.
17 * @var string
18 */
19 private $name = '';
20
21 /**
22 * @var array
23 */
24 private $values;
25
26 public function __construct(array $values)
27 {
28 $this->values = $values;
29 }
30
31 public function getName() : string
32 {
33 return $this->name;
34 }
35
36 public function setName(string $name)
37 {
38 $this->name = $name;
39 }
40
41 public function getValues() : array
42 {
43 return $this->values;
44 }
45
46 public function replaceNestedDefinitions(callable $replacer)
47 {
48 $this->values = array_map($replacer, $this->values);
49 }
50
51 public function __toString()
52 {
53 $str = '[' . PHP_EOL;
54
55 foreach ($this->values as $key => $value) {
56 if (is_string($key)) {
57 $key = "'" . $key . "'";
58 }
59
60 $str .= ' ' . $key . ' => ';
61
62 if ($value instanceof Definition) {
63 $str .= str_replace(PHP_EOL, PHP_EOL . ' ', (string) $value);
64 } else {
65 $str .= var_export($value, true);
66 }
67
68 $str .= ',' . PHP_EOL;
69 }
70
71 return $str . ']';
72 }
73 }
74