Plugin.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <?php
  2. /**
  3. * Server Plugin value object
  4. * @package PhpMyAdmin\Server
  5. */
  6. declare(strict_types=1);
  7. namespace PhpMyAdmin\Server;
  8. /**
  9. * Server Plugin value object
  10. * @package PhpMyAdmin\Server
  11. */
  12. final class Plugin
  13. {
  14. /**
  15. * @var string
  16. */
  17. private $name;
  18. /**
  19. * @var string|null
  20. */
  21. private $version;
  22. /**
  23. * @var string
  24. */
  25. private $status;
  26. /**
  27. * @var string
  28. */
  29. private $type;
  30. /**
  31. * @var string|null
  32. */
  33. private $typeVersion;
  34. /**
  35. * @var string|null
  36. */
  37. private $library;
  38. /**
  39. * @var string|null
  40. */
  41. private $libraryVersion;
  42. /**
  43. * @var string|null
  44. */
  45. private $author;
  46. /**
  47. * @var string|null
  48. */
  49. private $description;
  50. /**
  51. * @var string
  52. */
  53. private $license;
  54. /**
  55. * @var string|null
  56. */
  57. private $loadOption;
  58. /**
  59. * @var string|null
  60. */
  61. private $maturity;
  62. /**
  63. * @var string|null
  64. */
  65. private $authVersion;
  66. /**
  67. * @param string $name Name of the plugin
  68. * @param string|null $version Version from the plugin's general type descriptor
  69. * @param string $status Plugin status
  70. * @param string $type Type of plugin
  71. * @param string|null $typeVersion Version from the plugin's type-specific descriptor
  72. * @param string|null $library Plugin's shared object file name
  73. * @param string|null $libraryVersion Version from the plugin's API interface
  74. * @param string|null $author Author of the plugin
  75. * @param string|null $description Description
  76. * @param string $license Plugin's licence
  77. * @param string|null $loadOption How the plugin was loaded
  78. * @param string|null $maturity Plugin's maturity level
  79. * @param string|null $authVersion Plugin's version as determined by the plugin author
  80. */
  81. private function __construct(
  82. string $name,
  83. ?string $version,
  84. string $status,
  85. string $type,
  86. ?string $typeVersion,
  87. ?string $library,
  88. ?string $libraryVersion,
  89. ?string $author,
  90. ?string $description,
  91. string $license,
  92. ?string $loadOption,
  93. ?string $maturity,
  94. ?string $authVersion
  95. ) {
  96. $this->name = $name;
  97. $this->version = $version;
  98. $this->status = $status;
  99. $this->type = $type;
  100. $this->typeVersion = $typeVersion;
  101. $this->library = $library;
  102. $this->libraryVersion = $libraryVersion;
  103. $this->author = $author;
  104. $this->description = $description;
  105. $this->license = $license;
  106. $this->loadOption = $loadOption;
  107. $this->maturity = $maturity;
  108. $this->authVersion = $authVersion;
  109. }
  110. /**
  111. * @param array $state array with the properties
  112. * @return self
  113. */
  114. public static function fromState(array $state): self
  115. {
  116. return new self(
  117. $state['name'] ?? '',
  118. $state['version'] ?? null,
  119. $state['status'] ?? '',
  120. $state['type'] ?? '',
  121. $state['typeVersion'] ?? null,
  122. $state['library'] ?? null,
  123. $state['libraryVersion'] ?? null,
  124. $state['author'] ?? null,
  125. $state['description'] ?? null,
  126. $state['license'] ?? '',
  127. $state['loadOption'] ?? null,
  128. $state['maturity'] ?? null,
  129. $state['authVersion'] ?? null
  130. );
  131. }
  132. /**
  133. * @return array
  134. */
  135. public function toArray(): array
  136. {
  137. return [
  138. 'name' => $this->getName(),
  139. 'version' => $this->getVersion(),
  140. 'status' => $this->getStatus(),
  141. 'type' => $this->getType(),
  142. 'type_version' => $this->getTypeVersion(),
  143. 'library' => $this->getLibrary(),
  144. 'library_version' => $this->getLibraryVersion(),
  145. 'author' => $this->getAuthor(),
  146. 'description' => $this->getDescription(),
  147. 'license' => $this->getLicense(),
  148. 'load_option' => $this->getLoadOption(),
  149. 'maturity' => $this->getMaturity(),
  150. 'auth_version' => $this->getAuthVersion(),
  151. ];
  152. }
  153. /**
  154. * @return string
  155. */
  156. public function getName(): string
  157. {
  158. return $this->name;
  159. }
  160. /**
  161. * @return string|null
  162. */
  163. public function getVersion(): ?string
  164. {
  165. return $this->version;
  166. }
  167. /**
  168. * @return string
  169. */
  170. public function getStatus(): string
  171. {
  172. return $this->status;
  173. }
  174. /**
  175. * @return string
  176. */
  177. public function getType(): string
  178. {
  179. return $this->type;
  180. }
  181. /**
  182. * @return string|null
  183. */
  184. public function getTypeVersion(): ?string
  185. {
  186. return $this->typeVersion;
  187. }
  188. /**
  189. * @return string|null
  190. */
  191. public function getLibrary(): ?string
  192. {
  193. return $this->library;
  194. }
  195. /**
  196. * @return string|null
  197. */
  198. public function getLibraryVersion(): ?string
  199. {
  200. return $this->libraryVersion;
  201. }
  202. /**
  203. * @return string|null
  204. */
  205. public function getAuthor(): ?string
  206. {
  207. return $this->author;
  208. }
  209. /**
  210. * @return string|null
  211. */
  212. public function getDescription(): ?string
  213. {
  214. return $this->description;
  215. }
  216. /**
  217. * @return string
  218. */
  219. public function getLicense(): string
  220. {
  221. return $this->license;
  222. }
  223. /**
  224. * @return string|null
  225. */
  226. public function getLoadOption(): ?string
  227. {
  228. return $this->loadOption;
  229. }
  230. /**
  231. * @return string|null
  232. */
  233. public function getMaturity(): ?string
  234. {
  235. return $this->maturity;
  236. }
  237. /**
  238. * @return string|null
  239. */
  240. public function getAuthVersion(): ?string
  241. {
  242. return $this->authVersion;
  243. }
  244. }