GetApiV3SearchSuggestions200ResponseDataInner.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <?php
  2. /**
  3. * GetApiV3SearchSuggestions200ResponseDataInner
  4. *
  5. * PHP version 8.1
  6. *
  7. * @category Class
  8. * @package WikipaliApi
  9. * @author OpenAPI Generator team
  10. * @link https://openapi-generator.tech
  11. */
  12. /**
  13. * MINT API
  14. *
  15. * International Academy Of Pali Tipitaka(国际巴利三藏学院) 由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
  16. *
  17. * The version of the OpenAPI document: 1.0.0
  18. * Generated by: https://openapi-generator.tech
  19. * Generator version: 7.25.0
  20. */
  21. /**
  22. * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
  23. * https://openapi-generator.tech
  24. * Do not edit the class manually.
  25. */
  26. namespace WikipaliApi\Model;
  27. use \ArrayAccess;
  28. use \WikipaliApi\ObjectSerializer;
  29. /**
  30. * GetApiV3SearchSuggestions200ResponseDataInner Class Doc Comment
  31. *
  32. * @category Class
  33. * @package WikipaliApi
  34. * @author OpenAPI Generator team
  35. * @link https://openapi-generator.tech
  36. * @implements \ArrayAccess<string, mixed>
  37. */
  38. class GetApiV3SearchSuggestions200ResponseDataInner implements ModelInterface, ArrayAccess, \JsonSerializable
  39. {
  40. public const DISCRIMINATOR = null;
  41. /**
  42. * The original name of the model.
  43. *
  44. * @var string
  45. */
  46. protected static $openAPIModelName = 'get_api_v3_search_suggestions_200_response_data_inner';
  47. /**
  48. * Array of property to type mappings. Used for (de)serialization
  49. *
  50. * @var string[]
  51. */
  52. protected static $openAPITypes = [
  53. 'text' => 'string',
  54. 'source' => 'string',
  55. 'score' => 'float',
  56. 'doc_id' => 'string',
  57. 'resource_type' => 'string',
  58. 'language' => 'string',
  59. 'granularity' => 'string',
  60. 'category' => 'string[]'
  61. ];
  62. /**
  63. * Array of property to format mappings. Used for (de)serialization
  64. *
  65. * @var string[]
  66. * @phpstan-var array<string, string|null>
  67. * @psalm-var array<string, string|null>
  68. */
  69. protected static $openAPIFormats = [
  70. 'text' => null,
  71. 'source' => null,
  72. 'score' => null,
  73. 'doc_id' => null,
  74. 'resource_type' => null,
  75. 'language' => null,
  76. 'granularity' => null,
  77. 'category' => null
  78. ];
  79. /**
  80. * Array of nullable properties. Used for (de)serialization
  81. *
  82. * @var boolean[]
  83. */
  84. protected static array $openAPINullables = [
  85. 'text' => false,
  86. 'source' => false,
  87. 'score' => false,
  88. 'doc_id' => true,
  89. 'resource_type' => true,
  90. 'language' => true,
  91. 'granularity' => true,
  92. 'category' => false
  93. ];
  94. /**
  95. * If a nullable field gets set to null, insert it here
  96. *
  97. * @var boolean[]
  98. */
  99. protected array $openAPINullablesSetToNull = [];
  100. /**
  101. * Array of property to type mappings. Used for (de)serialization
  102. *
  103. * @return array
  104. */
  105. public static function openAPITypes()
  106. {
  107. return self::$openAPITypes;
  108. }
  109. /**
  110. * Array of property to format mappings. Used for (de)serialization
  111. *
  112. * @return array
  113. */
  114. public static function openAPIFormats()
  115. {
  116. return self::$openAPIFormats;
  117. }
  118. /**
  119. * Array of nullable properties
  120. *
  121. * @return array
  122. */
  123. protected static function openAPINullables(): array
  124. {
  125. return self::$openAPINullables;
  126. }
  127. /**
  128. * Array of nullable field names deliberately set to null
  129. *
  130. * @return boolean[]
  131. */
  132. private function getOpenAPINullablesSetToNull(): array
  133. {
  134. return $this->openAPINullablesSetToNull;
  135. }
  136. /**
  137. * Setter - Array of nullable field names deliberately set to null
  138. *
  139. * @param boolean[] $openAPINullablesSetToNull
  140. */
  141. private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
  142. {
  143. $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
  144. }
  145. /**
  146. * Checks if a property is nullable
  147. *
  148. * @param string $property
  149. * @return bool
  150. */
  151. public static function isNullable(string $property): bool
  152. {
  153. return self::openAPINullables()[$property] ?? false;
  154. }
  155. /**
  156. * Checks if a nullable property is set to null.
  157. *
  158. * @param string $property
  159. * @return bool
  160. */
  161. public function isNullableSetToNull(string $property): bool
  162. {
  163. return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
  164. }
  165. /**
  166. * Array of attributes where the key is the local name,
  167. * and the value is the original name
  168. *
  169. * @var string[]
  170. */
  171. protected static $attributeMap = [
  172. 'text' => 'text',
  173. 'source' => 'source',
  174. 'score' => 'score',
  175. 'doc_id' => 'doc_id',
  176. 'resource_type' => 'resource_type',
  177. 'language' => 'language',
  178. 'granularity' => 'granularity',
  179. 'category' => 'category'
  180. ];
  181. /**
  182. * Array of attributes to setter functions (for deserialization of responses)
  183. *
  184. * @var string[]
  185. */
  186. protected static $setters = [
  187. 'text' => 'setText',
  188. 'source' => 'setSource',
  189. 'score' => 'setScore',
  190. 'doc_id' => 'setDocId',
  191. 'resource_type' => 'setResourceType',
  192. 'language' => 'setLanguage',
  193. 'granularity' => 'setGranularity',
  194. 'category' => 'setCategory'
  195. ];
  196. /**
  197. * Array of attributes to getter functions (for serialization of requests)
  198. *
  199. * @var string[]
  200. */
  201. protected static $getters = [
  202. 'text' => 'getText',
  203. 'source' => 'getSource',
  204. 'score' => 'getScore',
  205. 'doc_id' => 'getDocId',
  206. 'resource_type' => 'getResourceType',
  207. 'language' => 'getLanguage',
  208. 'granularity' => 'getGranularity',
  209. 'category' => 'getCategory'
  210. ];
  211. /**
  212. * Array of attributes where the key is the local name,
  213. * and the value is the original name
  214. *
  215. * @return array
  216. */
  217. public static function attributeMap()
  218. {
  219. return self::$attributeMap;
  220. }
  221. /**
  222. * Array of attributes to setter functions (for deserialization of responses)
  223. *
  224. * @return array
  225. */
  226. public static function setters()
  227. {
  228. return self::$setters;
  229. }
  230. /**
  231. * Array of attributes to getter functions (for serialization of requests)
  232. *
  233. * @return array
  234. */
  235. public static function getters()
  236. {
  237. return self::$getters;
  238. }
  239. /**
  240. * The original name of the model.
  241. *
  242. * @return string
  243. */
  244. public function getModelName()
  245. {
  246. return self::$openAPIModelName;
  247. }
  248. /**
  249. * Associative array for storing property values
  250. *
  251. * @var mixed[]
  252. */
  253. protected $container = [];
  254. /**
  255. * Constructor
  256. *
  257. * @param mixed[]|null $data Associated array of property values
  258. * initializing the model
  259. */
  260. public function __construct(?array $data = null)
  261. {
  262. $this->setIfExists('text', $data ?? [], null);
  263. $this->setIfExists('source', $data ?? [], null);
  264. $this->setIfExists('score', $data ?? [], null);
  265. $this->setIfExists('doc_id', $data ?? [], null);
  266. $this->setIfExists('resource_type', $data ?? [], null);
  267. $this->setIfExists('language', $data ?? [], null);
  268. $this->setIfExists('granularity', $data ?? [], null);
  269. $this->setIfExists('category', $data ?? [], null);
  270. }
  271. /**
  272. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  273. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  274. * $this->openAPINullablesSetToNull array
  275. *
  276. * @param string $variableName
  277. * @param array $fields
  278. * @param mixed $defaultValue
  279. */
  280. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  281. {
  282. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  283. $this->openAPINullablesSetToNull[] = $variableName;
  284. }
  285. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  286. }
  287. /**
  288. * Show all the invalid properties with reasons.
  289. *
  290. * @return array invalid properties with reasons
  291. */
  292. public function listInvalidProperties()
  293. {
  294. $invalidProperties = [];
  295. return $invalidProperties;
  296. }
  297. /**
  298. * Validate all the properties in the model
  299. * return true if all passed
  300. *
  301. * @return bool True if all properties are valid
  302. */
  303. public function valid()
  304. {
  305. return count($this->listInvalidProperties()) === 0;
  306. }
  307. /**
  308. * Gets text
  309. *
  310. * @return string|null
  311. */
  312. public function getText()
  313. {
  314. return $this->container['text'];
  315. }
  316. /**
  317. * Sets text
  318. *
  319. * @param string|null $text text
  320. *
  321. * @return self
  322. */
  323. public function setText($text)
  324. {
  325. if (is_null($text)) {
  326. throw new \InvalidArgumentException('non-nullable text cannot be null');
  327. }
  328. $this->container['text'] = $text;
  329. return $this;
  330. }
  331. /**
  332. * Gets source
  333. *
  334. * @return string|null
  335. */
  336. public function getSource()
  337. {
  338. return $this->container['source'];
  339. }
  340. /**
  341. * Sets source
  342. *
  343. * @param string|null $source source
  344. *
  345. * @return self
  346. */
  347. public function setSource($source)
  348. {
  349. if (is_null($source)) {
  350. throw new \InvalidArgumentException('non-nullable source cannot be null');
  351. }
  352. $this->container['source'] = $source;
  353. return $this;
  354. }
  355. /**
  356. * Gets score
  357. *
  358. * @return float|null
  359. */
  360. public function getScore()
  361. {
  362. return $this->container['score'];
  363. }
  364. /**
  365. * Sets score
  366. *
  367. * @param float|null $score score
  368. *
  369. * @return self
  370. */
  371. public function setScore($score)
  372. {
  373. if (is_null($score)) {
  374. throw new \InvalidArgumentException('non-nullable score cannot be null');
  375. }
  376. $this->container['score'] = $score;
  377. return $this;
  378. }
  379. /**
  380. * Gets doc_id
  381. *
  382. * @return string|null
  383. */
  384. public function getDocId()
  385. {
  386. return $this->container['doc_id'];
  387. }
  388. /**
  389. * Sets doc_id
  390. *
  391. * @param string|null $doc_id doc_id
  392. *
  393. * @return self
  394. */
  395. public function setDocId($doc_id)
  396. {
  397. if (is_null($doc_id)) {
  398. array_push($this->openAPINullablesSetToNull, 'doc_id');
  399. } else {
  400. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  401. $index = array_search('doc_id', $nullablesSetToNull);
  402. if ($index !== FALSE) {
  403. unset($nullablesSetToNull[$index]);
  404. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  405. }
  406. }
  407. $this->container['doc_id'] = $doc_id;
  408. return $this;
  409. }
  410. /**
  411. * Gets resource_type
  412. *
  413. * @return string|null
  414. */
  415. public function getResourceType()
  416. {
  417. return $this->container['resource_type'];
  418. }
  419. /**
  420. * Sets resource_type
  421. *
  422. * @param string|null $resource_type resource_type
  423. *
  424. * @return self
  425. */
  426. public function setResourceType($resource_type)
  427. {
  428. if (is_null($resource_type)) {
  429. array_push($this->openAPINullablesSetToNull, 'resource_type');
  430. } else {
  431. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  432. $index = array_search('resource_type', $nullablesSetToNull);
  433. if ($index !== FALSE) {
  434. unset($nullablesSetToNull[$index]);
  435. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  436. }
  437. }
  438. $this->container['resource_type'] = $resource_type;
  439. return $this;
  440. }
  441. /**
  442. * Gets language
  443. *
  444. * @return string|null
  445. */
  446. public function getLanguage()
  447. {
  448. return $this->container['language'];
  449. }
  450. /**
  451. * Sets language
  452. *
  453. * @param string|null $language language
  454. *
  455. * @return self
  456. */
  457. public function setLanguage($language)
  458. {
  459. if (is_null($language)) {
  460. array_push($this->openAPINullablesSetToNull, 'language');
  461. } else {
  462. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  463. $index = array_search('language', $nullablesSetToNull);
  464. if ($index !== FALSE) {
  465. unset($nullablesSetToNull[$index]);
  466. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  467. }
  468. }
  469. $this->container['language'] = $language;
  470. return $this;
  471. }
  472. /**
  473. * Gets granularity
  474. *
  475. * @return string|null
  476. */
  477. public function getGranularity()
  478. {
  479. return $this->container['granularity'];
  480. }
  481. /**
  482. * Sets granularity
  483. *
  484. * @param string|null $granularity granularity
  485. *
  486. * @return self
  487. */
  488. public function setGranularity($granularity)
  489. {
  490. if (is_null($granularity)) {
  491. array_push($this->openAPINullablesSetToNull, 'granularity');
  492. } else {
  493. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  494. $index = array_search('granularity', $nullablesSetToNull);
  495. if ($index !== FALSE) {
  496. unset($nullablesSetToNull[$index]);
  497. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  498. }
  499. }
  500. $this->container['granularity'] = $granularity;
  501. return $this;
  502. }
  503. /**
  504. * Gets category
  505. *
  506. * @return string[]|null
  507. */
  508. public function getCategory()
  509. {
  510. return $this->container['category'];
  511. }
  512. /**
  513. * Sets category
  514. *
  515. * @param string[]|null $category category
  516. *
  517. * @return self
  518. */
  519. public function setCategory($category)
  520. {
  521. if (is_null($category)) {
  522. throw new \InvalidArgumentException('non-nullable category cannot be null');
  523. }
  524. $this->container['category'] = $category;
  525. return $this;
  526. }
  527. /**
  528. * Returns true if offset exists. False otherwise.
  529. *
  530. * @param integer|string $offset Offset
  531. *
  532. * @return boolean
  533. */
  534. public function offsetExists(mixed $offset): bool
  535. {
  536. return isset($this->container[$offset]);
  537. }
  538. /**
  539. * Gets offset.
  540. *
  541. * @param integer|string $offset Offset
  542. *
  543. * @return mixed|null
  544. */
  545. #[\ReturnTypeWillChange]
  546. public function offsetGet(mixed $offset)
  547. {
  548. return $this->container[$offset] ?? null;
  549. }
  550. /**
  551. * Sets value based on offset.
  552. *
  553. * @param int|null $offset Offset
  554. * @param mixed $value Value to be set
  555. *
  556. * @return void
  557. */
  558. public function offsetSet($offset, $value): void
  559. {
  560. if (is_null($offset)) {
  561. $this->container[] = $value;
  562. } else {
  563. $this->container[$offset] = $value;
  564. }
  565. }
  566. /**
  567. * Unsets offset.
  568. *
  569. * @param integer|string $offset Offset
  570. *
  571. * @return void
  572. */
  573. public function offsetUnset(mixed $offset): void
  574. {
  575. unset($this->container[$offset]);
  576. }
  577. /**
  578. * Serializes the object to a value that can be serialized natively by json_encode().
  579. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  580. *
  581. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  582. * of any type other than a resource.
  583. */
  584. #[\ReturnTypeWillChange]
  585. public function jsonSerialize()
  586. {
  587. return ObjectSerializer::sanitizeForSerialization($this);
  588. }
  589. /**
  590. * Gets the string presentation of the object
  591. *
  592. * @return string
  593. */
  594. public function __toString()
  595. {
  596. return json_encode(
  597. ObjectSerializer::sanitizeForSerialization($this),
  598. JSON_PRETTY_PRINT
  599. );
  600. }
  601. /**
  602. * Gets a header-safe presentation of the object
  603. *
  604. * @return string
  605. */
  606. public function toHeaderValue()
  607. {
  608. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  609. }
  610. }