PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.8.0
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.8.0
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 4.8.0, at includes/Dependencies/DI/Definition/ArrayDefinition.php

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