PatchApiV3TermsTermRequest.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  1. <?php
  2. /**
  3. * PatchApiV3TermsTermRequest
  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. * PatchApiV3TermsTermRequest 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 PatchApiV3TermsTermRequest 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 = 'patch_api_v3_terms_term__request';
  47. /**
  48. * Array of property to type mappings. Used for (de)serialization
  49. *
  50. * @var string[]
  51. */
  52. protected static $openAPITypes = [
  53. 'meaning' => 'string',
  54. 'other_meaning' => 'string',
  55. 'note' => 'string',
  56. 'summary' => 'string',
  57. 'quality' => 'string',
  58. 'content_type' => 'string',
  59. 'redirect' => 'string',
  60. 'language' => '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. 'meaning' => null,
  71. 'other_meaning' => null,
  72. 'note' => null,
  73. 'summary' => null,
  74. 'quality' => null,
  75. 'content_type' => null,
  76. 'redirect' => null,
  77. 'language' => null
  78. ];
  79. /**
  80. * Array of nullable properties. Used for (de)serialization
  81. *
  82. * @var boolean[]
  83. */
  84. protected static array $openAPINullables = [
  85. 'meaning' => false,
  86. 'other_meaning' => true,
  87. 'note' => true,
  88. 'summary' => true,
  89. 'quality' => true,
  90. 'content_type' => false,
  91. 'redirect' => true,
  92. 'language' => 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. 'meaning' => 'meaning',
  173. 'other_meaning' => 'other_meaning',
  174. 'note' => 'note',
  175. 'summary' => 'summary',
  176. 'quality' => 'quality',
  177. 'content_type' => 'content_type',
  178. 'redirect' => 'redirect',
  179. 'language' => 'language'
  180. ];
  181. /**
  182. * Array of attributes to setter functions (for deserialization of responses)
  183. *
  184. * @var string[]
  185. */
  186. protected static $setters = [
  187. 'meaning' => 'setMeaning',
  188. 'other_meaning' => 'setOtherMeaning',
  189. 'note' => 'setNote',
  190. 'summary' => 'setSummary',
  191. 'quality' => 'setQuality',
  192. 'content_type' => 'setContentType',
  193. 'redirect' => 'setRedirect',
  194. 'language' => 'setLanguage'
  195. ];
  196. /**
  197. * Array of attributes to getter functions (for serialization of requests)
  198. *
  199. * @var string[]
  200. */
  201. protected static $getters = [
  202. 'meaning' => 'getMeaning',
  203. 'other_meaning' => 'getOtherMeaning',
  204. 'note' => 'getNote',
  205. 'summary' => 'getSummary',
  206. 'quality' => 'getQuality',
  207. 'content_type' => 'getContentType',
  208. 'redirect' => 'getRedirect',
  209. 'language' => 'getLanguage'
  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. public const QUALITY_FEATURED = 'featured';
  249. public const QUALITY_STANDARD = 'standard';
  250. public const QUALITY_DRAFT = 'draft';
  251. public const QUALITY_PENDING = 'pending';
  252. public const CONTENT_TYPE_MARKDOWN = 'markdown';
  253. public const CONTENT_TYPE_MARKDOWN_E2 = 'markdown-e2';
  254. /**
  255. * Gets allowable values of the enum
  256. *
  257. * @return string[]
  258. */
  259. public function getQualityAllowableValues()
  260. {
  261. return [
  262. self::QUALITY_FEATURED,
  263. self::QUALITY_STANDARD,
  264. self::QUALITY_DRAFT,
  265. self::QUALITY_PENDING,
  266. ];
  267. }
  268. /**
  269. * Gets allowable values of the enum
  270. *
  271. * @return string[]
  272. */
  273. public function getContentTypeAllowableValues()
  274. {
  275. return [
  276. self::CONTENT_TYPE_MARKDOWN,
  277. self::CONTENT_TYPE_MARKDOWN_E2,
  278. ];
  279. }
  280. /**
  281. * Associative array for storing property values
  282. *
  283. * @var mixed[]
  284. */
  285. protected $container = [];
  286. /**
  287. * Constructor
  288. *
  289. * @param mixed[]|null $data Associated array of property values
  290. * initializing the model
  291. */
  292. public function __construct(?array $data = null)
  293. {
  294. $this->setIfExists('meaning', $data ?? [], null);
  295. $this->setIfExists('other_meaning', $data ?? [], null);
  296. $this->setIfExists('note', $data ?? [], null);
  297. $this->setIfExists('summary', $data ?? [], null);
  298. $this->setIfExists('quality', $data ?? [], null);
  299. $this->setIfExists('content_type', $data ?? [], null);
  300. $this->setIfExists('redirect', $data ?? [], null);
  301. $this->setIfExists('language', $data ?? [], null);
  302. }
  303. /**
  304. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  305. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  306. * $this->openAPINullablesSetToNull array
  307. *
  308. * @param string $variableName
  309. * @param array $fields
  310. * @param mixed $defaultValue
  311. */
  312. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  313. {
  314. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  315. $this->openAPINullablesSetToNull[] = $variableName;
  316. }
  317. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  318. }
  319. /**
  320. * Show all the invalid properties with reasons.
  321. *
  322. * @return array invalid properties with reasons
  323. */
  324. public function listInvalidProperties()
  325. {
  326. $invalidProperties = [];
  327. $allowedValues = $this->getQualityAllowableValues();
  328. if (!is_null($this->container['quality']) && !in_array($this->container['quality'], $allowedValues, true)) {
  329. $invalidProperties[] = sprintf(
  330. "invalid value '%s' for 'quality', must be one of '%s'",
  331. $this->container['quality'],
  332. implode("', '", $allowedValues)
  333. );
  334. }
  335. $allowedValues = $this->getContentTypeAllowableValues();
  336. if (!is_null($this->container['content_type']) && !in_array($this->container['content_type'], $allowedValues, true)) {
  337. $invalidProperties[] = sprintf(
  338. "invalid value '%s' for 'content_type', must be one of '%s'",
  339. $this->container['content_type'],
  340. implode("', '", $allowedValues)
  341. );
  342. }
  343. return $invalidProperties;
  344. }
  345. /**
  346. * Validate all the properties in the model
  347. * return true if all passed
  348. *
  349. * @return bool True if all properties are valid
  350. */
  351. public function valid()
  352. {
  353. return count($this->listInvalidProperties()) === 0;
  354. }
  355. /**
  356. * Gets meaning
  357. *
  358. * @return string|null
  359. */
  360. public function getMeaning()
  361. {
  362. return $this->container['meaning'];
  363. }
  364. /**
  365. * Sets meaning
  366. *
  367. * @param string|null $meaning 释义
  368. *
  369. * @return self
  370. */
  371. public function setMeaning($meaning)
  372. {
  373. if (is_null($meaning)) {
  374. throw new \InvalidArgumentException('non-nullable meaning cannot be null');
  375. }
  376. $this->container['meaning'] = $meaning;
  377. return $this;
  378. }
  379. /**
  380. * Gets other_meaning
  381. *
  382. * @return string|null
  383. */
  384. public function getOtherMeaning()
  385. {
  386. return $this->container['other_meaning'];
  387. }
  388. /**
  389. * Sets other_meaning
  390. *
  391. * @param string|null $other_meaning 其它释义
  392. *
  393. * @return self
  394. */
  395. public function setOtherMeaning($other_meaning)
  396. {
  397. if (is_null($other_meaning)) {
  398. array_push($this->openAPINullablesSetToNull, 'other_meaning');
  399. } else {
  400. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  401. $index = array_search('other_meaning', $nullablesSetToNull);
  402. if ($index !== FALSE) {
  403. unset($nullablesSetToNull[$index]);
  404. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  405. }
  406. }
  407. $this->container['other_meaning'] = $other_meaning;
  408. return $this;
  409. }
  410. /**
  411. * Gets note
  412. *
  413. * @return string|null
  414. */
  415. public function getNote()
  416. {
  417. return $this->container['note'];
  418. }
  419. /**
  420. * Sets note
  421. *
  422. * @param string|null $note 正文
  423. *
  424. * @return self
  425. */
  426. public function setNote($note)
  427. {
  428. if (is_null($note)) {
  429. array_push($this->openAPINullablesSetToNull, 'note');
  430. } else {
  431. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  432. $index = array_search('note', $nullablesSetToNull);
  433. if ($index !== FALSE) {
  434. unset($nullablesSetToNull[$index]);
  435. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  436. }
  437. }
  438. $this->container['note'] = $note;
  439. return $this;
  440. }
  441. /**
  442. * Gets summary
  443. *
  444. * @return string|null
  445. */
  446. public function getSummary()
  447. {
  448. return $this->container['summary'];
  449. }
  450. /**
  451. * Sets summary
  452. *
  453. * @param string|null $summary 摘要,格式与 note 相同
  454. *
  455. * @return self
  456. */
  457. public function setSummary($summary)
  458. {
  459. if (is_null($summary)) {
  460. array_push($this->openAPINullablesSetToNull, 'summary');
  461. } else {
  462. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  463. $index = array_search('summary', $nullablesSetToNull);
  464. if ($index !== FALSE) {
  465. unset($nullablesSetToNull[$index]);
  466. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  467. }
  468. }
  469. $this->container['summary'] = $summary;
  470. return $this;
  471. }
  472. /**
  473. * Gets quality
  474. *
  475. * @return string|null
  476. */
  477. public function getQuality()
  478. {
  479. return $this->container['quality'];
  480. }
  481. /**
  482. * Sets quality
  483. *
  484. * @param string|null $quality 质量
  485. *
  486. * @return self
  487. */
  488. public function setQuality($quality)
  489. {
  490. if (is_null($quality)) {
  491. array_push($this->openAPINullablesSetToNull, 'quality');
  492. } else {
  493. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  494. $index = array_search('quality', $nullablesSetToNull);
  495. if ($index !== FALSE) {
  496. unset($nullablesSetToNull[$index]);
  497. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  498. }
  499. }
  500. $allowedValues = $this->getQualityAllowableValues();
  501. if (!is_null($quality) && !in_array($quality, $allowedValues, true)) {
  502. throw new \InvalidArgumentException(
  503. sprintf(
  504. "Invalid value '%s' for 'quality', must be one of '%s'",
  505. $quality,
  506. implode("', '", $allowedValues)
  507. )
  508. );
  509. }
  510. $this->container['quality'] = $quality;
  511. return $this;
  512. }
  513. /**
  514. * Gets content_type
  515. *
  516. * @return string|null
  517. */
  518. public function getContentType()
  519. {
  520. return $this->container['content_type'];
  521. }
  522. /**
  523. * Sets content_type
  524. *
  525. * @param string|null $content_type 正文方言
  526. *
  527. * @return self
  528. */
  529. public function setContentType($content_type)
  530. {
  531. if (is_null($content_type)) {
  532. throw new \InvalidArgumentException('non-nullable content_type cannot be null');
  533. }
  534. $allowedValues = $this->getContentTypeAllowableValues();
  535. if (!in_array($content_type, $allowedValues, true)) {
  536. throw new \InvalidArgumentException(
  537. sprintf(
  538. "Invalid value '%s' for 'content_type', must be one of '%s'",
  539. $content_type,
  540. implode("', '", $allowedValues)
  541. )
  542. );
  543. }
  544. $this->container['content_type'] = $content_type;
  545. return $this;
  546. }
  547. /**
  548. * Gets redirect
  549. *
  550. * @return string|null
  551. */
  552. public function getRedirect()
  553. {
  554. return $this->container['redirect'];
  555. }
  556. /**
  557. * Sets redirect
  558. *
  559. * @param string|null $redirect 重定向到 word 或 word@tag
  560. *
  561. * @return self
  562. */
  563. public function setRedirect($redirect)
  564. {
  565. if (is_null($redirect)) {
  566. array_push($this->openAPINullablesSetToNull, 'redirect');
  567. } else {
  568. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  569. $index = array_search('redirect', $nullablesSetToNull);
  570. if ($index !== FALSE) {
  571. unset($nullablesSetToNull[$index]);
  572. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  573. }
  574. }
  575. $this->container['redirect'] = $redirect;
  576. return $this;
  577. }
  578. /**
  579. * Gets language
  580. *
  581. * @return string|null
  582. */
  583. public function getLanguage()
  584. {
  585. return $this->container['language'];
  586. }
  587. /**
  588. * Sets language
  589. *
  590. * @param string|null $language 语言(只有 studio 级术语能改)
  591. *
  592. * @return self
  593. */
  594. public function setLanguage($language)
  595. {
  596. if (is_null($language)) {
  597. throw new \InvalidArgumentException('non-nullable language cannot be null');
  598. }
  599. $this->container['language'] = $language;
  600. return $this;
  601. }
  602. /**
  603. * Returns true if offset exists. False otherwise.
  604. *
  605. * @param integer|string $offset Offset
  606. *
  607. * @return boolean
  608. */
  609. public function offsetExists(mixed $offset): bool
  610. {
  611. return isset($this->container[$offset]);
  612. }
  613. /**
  614. * Gets offset.
  615. *
  616. * @param integer|string $offset Offset
  617. *
  618. * @return mixed|null
  619. */
  620. #[\ReturnTypeWillChange]
  621. public function offsetGet(mixed $offset)
  622. {
  623. return $this->container[$offset] ?? null;
  624. }
  625. /**
  626. * Sets value based on offset.
  627. *
  628. * @param int|null $offset Offset
  629. * @param mixed $value Value to be set
  630. *
  631. * @return void
  632. */
  633. public function offsetSet($offset, $value): void
  634. {
  635. if (is_null($offset)) {
  636. $this->container[] = $value;
  637. } else {
  638. $this->container[$offset] = $value;
  639. }
  640. }
  641. /**
  642. * Unsets offset.
  643. *
  644. * @param integer|string $offset Offset
  645. *
  646. * @return void
  647. */
  648. public function offsetUnset(mixed $offset): void
  649. {
  650. unset($this->container[$offset]);
  651. }
  652. /**
  653. * Serializes the object to a value that can be serialized natively by json_encode().
  654. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  655. *
  656. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  657. * of any type other than a resource.
  658. */
  659. #[\ReturnTypeWillChange]
  660. public function jsonSerialize()
  661. {
  662. return ObjectSerializer::sanitizeForSerialization($this);
  663. }
  664. /**
  665. * Gets the string presentation of the object
  666. *
  667. * @return string
  668. */
  669. public function __toString()
  670. {
  671. return json_encode(
  672. ObjectSerializer::sanitizeForSerialization($this),
  673. JSON_PRETTY_PRINT
  674. );
  675. }
  676. /**
  677. * Gets a header-safe presentation of the object
  678. *
  679. * @return string
  680. */
  681. public function toHeaderValue()
  682. {
  683. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  684. }
  685. }