GetApiV3Discussions200ResponseDataInnerSentence.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <?php
  2. /**
  3. * GetApiV3Discussions200ResponseDataInnerSentence
  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: 2026.10.21
  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. * GetApiV3Discussions200ResponseDataInnerSentence Class Doc Comment
  31. *
  32. * @category Class
  33. * @description 仅在部分查询口径下返回。
  34. * @package WikipaliApi
  35. * @author OpenAPI Generator team
  36. * @link https://openapi-generator.tech
  37. * @implements \ArrayAccess<string, mixed>
  38. */
  39. class GetApiV3Discussions200ResponseDataInnerSentence implements ModelInterface, ArrayAccess, \JsonSerializable
  40. {
  41. public const DISCRIMINATOR = null;
  42. /**
  43. * The original name of the model.
  44. *
  45. * @var string
  46. */
  47. protected static $openAPIModelName = 'get_api_v3_discussions_200_response_data_inner_sentence';
  48. /**
  49. * Array of property to type mappings. Used for (de)serialization
  50. *
  51. * @var string[]
  52. */
  53. protected static $openAPITypes = [
  54. 'book' => 'int',
  55. 'paragraph' => 'int',
  56. 'word_start' => 'int',
  57. 'word_end' => 'int'
  58. ];
  59. /**
  60. * Array of property to format mappings. Used for (de)serialization
  61. *
  62. * @var string[]
  63. * @phpstan-var array<string, string|null>
  64. * @psalm-var array<string, string|null>
  65. */
  66. protected static $openAPIFormats = [
  67. 'book' => null,
  68. 'paragraph' => null,
  69. 'word_start' => null,
  70. 'word_end' => null
  71. ];
  72. /**
  73. * Array of nullable properties. Used for (de)serialization
  74. *
  75. * @var boolean[]
  76. */
  77. protected static array $openAPINullables = [
  78. 'book' => false,
  79. 'paragraph' => false,
  80. 'word_start' => false,
  81. 'word_end' => false
  82. ];
  83. /**
  84. * If a nullable field gets set to null, insert it here
  85. *
  86. * @var boolean[]
  87. */
  88. protected array $openAPINullablesSetToNull = [];
  89. /**
  90. * Array of property to type mappings. Used for (de)serialization
  91. *
  92. * @return array
  93. */
  94. public static function openAPITypes()
  95. {
  96. return self::$openAPITypes;
  97. }
  98. /**
  99. * Array of property to format mappings. Used for (de)serialization
  100. *
  101. * @return array
  102. */
  103. public static function openAPIFormats()
  104. {
  105. return self::$openAPIFormats;
  106. }
  107. /**
  108. * Array of nullable properties
  109. *
  110. * @return array
  111. */
  112. protected static function openAPINullables(): array
  113. {
  114. return self::$openAPINullables;
  115. }
  116. /**
  117. * Array of nullable field names deliberately set to null
  118. *
  119. * @return boolean[]
  120. */
  121. private function getOpenAPINullablesSetToNull(): array
  122. {
  123. return $this->openAPINullablesSetToNull;
  124. }
  125. /**
  126. * Setter - Array of nullable field names deliberately set to null
  127. *
  128. * @param boolean[] $openAPINullablesSetToNull
  129. */
  130. private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
  131. {
  132. $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
  133. }
  134. /**
  135. * Checks if a property is nullable
  136. *
  137. * @param string $property
  138. * @return bool
  139. */
  140. public static function isNullable(string $property): bool
  141. {
  142. return self::openAPINullables()[$property] ?? false;
  143. }
  144. /**
  145. * Checks if a nullable property is set to null.
  146. *
  147. * @param string $property
  148. * @return bool
  149. */
  150. public function isNullableSetToNull(string $property): bool
  151. {
  152. return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
  153. }
  154. /**
  155. * Array of attributes where the key is the local name,
  156. * and the value is the original name
  157. *
  158. * @var string[]
  159. */
  160. protected static $attributeMap = [
  161. 'book' => 'book',
  162. 'paragraph' => 'paragraph',
  163. 'word_start' => 'word_start',
  164. 'word_end' => 'word_end'
  165. ];
  166. /**
  167. * Array of attributes to setter functions (for deserialization of responses)
  168. *
  169. * @var string[]
  170. */
  171. protected static $setters = [
  172. 'book' => 'setBook',
  173. 'paragraph' => 'setParagraph',
  174. 'word_start' => 'setWordStart',
  175. 'word_end' => 'setWordEnd'
  176. ];
  177. /**
  178. * Array of attributes to getter functions (for serialization of requests)
  179. *
  180. * @var string[]
  181. */
  182. protected static $getters = [
  183. 'book' => 'getBook',
  184. 'paragraph' => 'getParagraph',
  185. 'word_start' => 'getWordStart',
  186. 'word_end' => 'getWordEnd'
  187. ];
  188. /**
  189. * Array of attributes where the key is the local name,
  190. * and the value is the original name
  191. *
  192. * @return array
  193. */
  194. public static function attributeMap()
  195. {
  196. return self::$attributeMap;
  197. }
  198. /**
  199. * Array of attributes to setter functions (for deserialization of responses)
  200. *
  201. * @return array
  202. */
  203. public static function setters()
  204. {
  205. return self::$setters;
  206. }
  207. /**
  208. * Array of attributes to getter functions (for serialization of requests)
  209. *
  210. * @return array
  211. */
  212. public static function getters()
  213. {
  214. return self::$getters;
  215. }
  216. /**
  217. * The original name of the model.
  218. *
  219. * @return string
  220. */
  221. public function getModelName()
  222. {
  223. return self::$openAPIModelName;
  224. }
  225. /**
  226. * Associative array for storing property values
  227. *
  228. * @var mixed[]
  229. */
  230. protected $container = [];
  231. /**
  232. * Constructor
  233. *
  234. * @param mixed[]|null $data Associated array of property values
  235. * initializing the model
  236. */
  237. public function __construct(?array $data = null)
  238. {
  239. $this->setIfExists('book', $data ?? [], null);
  240. $this->setIfExists('paragraph', $data ?? [], null);
  241. $this->setIfExists('word_start', $data ?? [], null);
  242. $this->setIfExists('word_end', $data ?? [], null);
  243. }
  244. /**
  245. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  246. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  247. * $this->openAPINullablesSetToNull array
  248. *
  249. * @param string $variableName
  250. * @param array $fields
  251. * @param mixed $defaultValue
  252. */
  253. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  254. {
  255. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  256. $this->openAPINullablesSetToNull[] = $variableName;
  257. }
  258. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  259. }
  260. /**
  261. * Show all the invalid properties with reasons.
  262. *
  263. * @return array invalid properties with reasons
  264. */
  265. public function listInvalidProperties()
  266. {
  267. $invalidProperties = [];
  268. return $invalidProperties;
  269. }
  270. /**
  271. * Validate all the properties in the model
  272. * return true if all passed
  273. *
  274. * @return bool True if all properties are valid
  275. */
  276. public function valid()
  277. {
  278. return count($this->listInvalidProperties()) === 0;
  279. }
  280. /**
  281. * Gets book
  282. *
  283. * @return int|null
  284. */
  285. public function getBook()
  286. {
  287. return $this->container['book'];
  288. }
  289. /**
  290. * Sets book
  291. *
  292. * @param int|null $book book
  293. *
  294. * @return self
  295. */
  296. public function setBook($book)
  297. {
  298. if (is_null($book)) {
  299. throw new \InvalidArgumentException('non-nullable book cannot be null');
  300. }
  301. $this->container['book'] = $book;
  302. return $this;
  303. }
  304. /**
  305. * Gets paragraph
  306. *
  307. * @return int|null
  308. */
  309. public function getParagraph()
  310. {
  311. return $this->container['paragraph'];
  312. }
  313. /**
  314. * Sets paragraph
  315. *
  316. * @param int|null $paragraph paragraph
  317. *
  318. * @return self
  319. */
  320. public function setParagraph($paragraph)
  321. {
  322. if (is_null($paragraph)) {
  323. throw new \InvalidArgumentException('non-nullable paragraph cannot be null');
  324. }
  325. $this->container['paragraph'] = $paragraph;
  326. return $this;
  327. }
  328. /**
  329. * Gets word_start
  330. *
  331. * @return int|null
  332. */
  333. public function getWordStart()
  334. {
  335. return $this->container['word_start'];
  336. }
  337. /**
  338. * Sets word_start
  339. *
  340. * @param int|null $word_start word_start
  341. *
  342. * @return self
  343. */
  344. public function setWordStart($word_start)
  345. {
  346. if (is_null($word_start)) {
  347. throw new \InvalidArgumentException('non-nullable word_start cannot be null');
  348. }
  349. $this->container['word_start'] = $word_start;
  350. return $this;
  351. }
  352. /**
  353. * Gets word_end
  354. *
  355. * @return int|null
  356. */
  357. public function getWordEnd()
  358. {
  359. return $this->container['word_end'];
  360. }
  361. /**
  362. * Sets word_end
  363. *
  364. * @param int|null $word_end word_end
  365. *
  366. * @return self
  367. */
  368. public function setWordEnd($word_end)
  369. {
  370. if (is_null($word_end)) {
  371. throw new \InvalidArgumentException('non-nullable word_end cannot be null');
  372. }
  373. $this->container['word_end'] = $word_end;
  374. return $this;
  375. }
  376. /**
  377. * Returns true if offset exists. False otherwise.
  378. *
  379. * @param integer|string $offset Offset
  380. *
  381. * @return boolean
  382. */
  383. public function offsetExists(mixed $offset): bool
  384. {
  385. return isset($this->container[$offset]);
  386. }
  387. /**
  388. * Gets offset.
  389. *
  390. * @param integer|string $offset Offset
  391. *
  392. * @return mixed|null
  393. */
  394. #[\ReturnTypeWillChange]
  395. public function offsetGet(mixed $offset)
  396. {
  397. return $this->container[$offset] ?? null;
  398. }
  399. /**
  400. * Sets value based on offset.
  401. *
  402. * @param int|null $offset Offset
  403. * @param mixed $value Value to be set
  404. *
  405. * @return void
  406. */
  407. public function offsetSet($offset, $value): void
  408. {
  409. if (is_null($offset)) {
  410. $this->container[] = $value;
  411. } else {
  412. $this->container[$offset] = $value;
  413. }
  414. }
  415. /**
  416. * Unsets offset.
  417. *
  418. * @param integer|string $offset Offset
  419. *
  420. * @return void
  421. */
  422. public function offsetUnset(mixed $offset): void
  423. {
  424. unset($this->container[$offset]);
  425. }
  426. /**
  427. * Serializes the object to a value that can be serialized natively by json_encode().
  428. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  429. *
  430. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  431. * of any type other than a resource.
  432. */
  433. #[\ReturnTypeWillChange]
  434. public function jsonSerialize()
  435. {
  436. return ObjectSerializer::sanitizeForSerialization($this);
  437. }
  438. /**
  439. * Gets the string presentation of the object
  440. *
  441. * @return string
  442. */
  443. public function __toString()
  444. {
  445. return json_encode(
  446. ObjectSerializer::sanitizeForSerialization($this),
  447. JSON_PRETTY_PRINT
  448. );
  449. }
  450. /**
  451. * Gets a header-safe presentation of the object
  452. *
  453. * @return string
  454. */
  455. public function toHeaderValue()
  456. {
  457. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  458. }
  459. }