1 | <?php |
||
21 | class Plugin extends AbstractDocument |
||
22 | { |
||
23 | /** |
||
24 | * name |
||
25 | * @var string $name |
||
26 | */ |
||
27 | protected $name = null; |
||
28 | |||
29 | /** |
||
30 | * consumer id |
||
31 | * @var string $consumerId |
||
32 | */ |
||
33 | protected $consumerId = null; |
||
34 | |||
35 | /** |
||
36 | * config |
||
37 | * @var array $config |
||
38 | */ |
||
39 | protected $config = []; |
||
40 | |||
41 | /** |
||
42 | * set name |
||
43 | * |
||
44 | * @param string $name |
||
45 | * |
||
46 | * @return this |
||
47 | */ |
||
48 | 1 | public function setName(string $name): self |
|
54 | |||
55 | /** |
||
56 | * get name |
||
57 | * |
||
58 | * @return string |
||
59 | */ |
||
60 | 1 | public function getName(): string |
|
64 | |||
65 | /** |
||
66 | * set consumer id |
||
67 | * |
||
68 | * @param string $consumerId |
||
69 | * |
||
70 | * @return this |
||
71 | */ |
||
72 | 1 | public function setConsumerId(string $consumerId): self |
|
78 | |||
79 | /** |
||
80 | * get consumer id |
||
81 | * |
||
82 | * @return string |
||
83 | */ |
||
84 | 1 | public function getConsumerId(): string |
|
88 | |||
89 | /** |
||
90 | * add config |
||
91 | * |
||
92 | * @param string $name |
||
93 | * @param mixed $value |
||
94 | * |
||
95 | * @return this |
||
96 | */ |
||
97 | 2 | public function addConfig(string $name, $value): self |
|
98 | { |
||
99 | 2 | if (isset($this->config[$name])) { |
|
100 | 1 | throw new \RuntimeException(sprintf('Config for name `%1$s` already set', $name)); |
|
101 | } |
||
102 | |||
103 | 2 | $this->config[$name] = $value; |
|
104 | |||
105 | 2 | return $this; |
|
106 | } |
||
107 | |||
108 | /** |
||
109 | * remove config |
||
110 | * |
||
111 | * @param string $name |
||
112 | * |
||
113 | * @return this |
||
114 | */ |
||
115 | 1 | public function removeConfig(string $name): self |
|
123 | |||
124 | /** |
||
125 | * get config |
||
126 | * |
||
127 | * @param string $name |
||
128 | * |
||
129 | * @return mixed |
||
130 | */ |
||
131 | 1 | public function getConfig(string $name) |
|
135 | |||
136 | /** |
||
137 | * get fields |
||
138 | * |
||
139 | * @return array |
||
140 | */ |
||
141 | 1 | protected function getFields(): array |
|
149 | |||
150 | /** |
||
151 | * to json |
||
152 | * |
||
153 | * @return string |
||
154 | */ |
||
155 | 1 | public function toJson(): string |
|
175 | } |
||
176 |