GetApiV3AdminReadingStats200ResponseDataTopChaptersInner.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. <?php
  2. /**
  3. * GetApiV3AdminReadingStats200ResponseDataTopChaptersInner
  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.11.12
  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. * GetApiV3AdminReadingStats200ResponseDataTopChaptersInner 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 GetApiV3AdminReadingStats200ResponseDataTopChaptersInner 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_admin_reading_stats_200_response_data_top_chapters_inner';
  47. /**
  48. * Array of property to type mappings. Used for (de)serialization
  49. *
  50. * @var string[]
  51. */
  52. protected static $openAPITypes = [
  53. 'article_id' => 'string',
  54. 'book' => 'int',
  55. 'paragraph' => 'int',
  56. 'title' => 'string',
  57. 'collection' => 'string',
  58. 'readers' => 'int',
  59. 'records' => 'int'
  60. ];
  61. /**
  62. * Array of property to format mappings. Used for (de)serialization
  63. *
  64. * @var string[]
  65. * @phpstan-var array<string, string|null>
  66. * @psalm-var array<string, string|null>
  67. */
  68. protected static $openAPIFormats = [
  69. 'article_id' => null,
  70. 'book' => null,
  71. 'paragraph' => null,
  72. 'title' => null,
  73. 'collection' => null,
  74. 'readers' => null,
  75. 'records' => null
  76. ];
  77. /**
  78. * Array of nullable properties. Used for (de)serialization
  79. *
  80. * @var boolean[]
  81. */
  82. protected static array $openAPINullables = [
  83. 'article_id' => false,
  84. 'book' => false,
  85. 'paragraph' => false,
  86. 'title' => false,
  87. 'collection' => true,
  88. 'readers' => false,
  89. 'records' => false
  90. ];
  91. /**
  92. * If a nullable field gets set to null, insert it here
  93. *
  94. * @var boolean[]
  95. */
  96. protected array $openAPINullablesSetToNull = [];
  97. /**
  98. * Array of property to type mappings. Used for (de)serialization
  99. *
  100. * @return array
  101. */
  102. public static function openAPITypes()
  103. {
  104. return self::$openAPITypes;
  105. }
  106. /**
  107. * Array of property to format mappings. Used for (de)serialization
  108. *
  109. * @return array
  110. */
  111. public static function openAPIFormats()
  112. {
  113. return self::$openAPIFormats;
  114. }
  115. /**
  116. * Array of nullable properties
  117. *
  118. * @return array
  119. */
  120. protected static function openAPINullables(): array
  121. {
  122. return self::$openAPINullables;
  123. }
  124. /**
  125. * Array of nullable field names deliberately set to null
  126. *
  127. * @return boolean[]
  128. */
  129. private function getOpenAPINullablesSetToNull(): array
  130. {
  131. return $this->openAPINullablesSetToNull;
  132. }
  133. /**
  134. * Setter - Array of nullable field names deliberately set to null
  135. *
  136. * @param boolean[] $openAPINullablesSetToNull
  137. */
  138. private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
  139. {
  140. $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
  141. }
  142. /**
  143. * Checks if a property is nullable
  144. *
  145. * @param string $property
  146. * @return bool
  147. */
  148. public static function isNullable(string $property): bool
  149. {
  150. return self::openAPINullables()[$property] ?? false;
  151. }
  152. /**
  153. * Checks if a nullable property is set to null.
  154. *
  155. * @param string $property
  156. * @return bool
  157. */
  158. public function isNullableSetToNull(string $property): bool
  159. {
  160. return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
  161. }
  162. /**
  163. * Array of attributes where the key is the local name,
  164. * and the value is the original name
  165. *
  166. * @var string[]
  167. */
  168. protected static $attributeMap = [
  169. 'article_id' => 'article_id',
  170. 'book' => 'book',
  171. 'paragraph' => 'paragraph',
  172. 'title' => 'title',
  173. 'collection' => 'collection',
  174. 'readers' => 'readers',
  175. 'records' => 'records'
  176. ];
  177. /**
  178. * Array of attributes to setter functions (for deserialization of responses)
  179. *
  180. * @var string[]
  181. */
  182. protected static $setters = [
  183. 'article_id' => 'setArticleId',
  184. 'book' => 'setBook',
  185. 'paragraph' => 'setParagraph',
  186. 'title' => 'setTitle',
  187. 'collection' => 'setCollection',
  188. 'readers' => 'setReaders',
  189. 'records' => 'setRecords'
  190. ];
  191. /**
  192. * Array of attributes to getter functions (for serialization of requests)
  193. *
  194. * @var string[]
  195. */
  196. protected static $getters = [
  197. 'article_id' => 'getArticleId',
  198. 'book' => 'getBook',
  199. 'paragraph' => 'getParagraph',
  200. 'title' => 'getTitle',
  201. 'collection' => 'getCollection',
  202. 'readers' => 'getReaders',
  203. 'records' => 'getRecords'
  204. ];
  205. /**
  206. * Array of attributes where the key is the local name,
  207. * and the value is the original name
  208. *
  209. * @return array
  210. */
  211. public static function attributeMap()
  212. {
  213. return self::$attributeMap;
  214. }
  215. /**
  216. * Array of attributes to setter functions (for deserialization of responses)
  217. *
  218. * @return array
  219. */
  220. public static function setters()
  221. {
  222. return self::$setters;
  223. }
  224. /**
  225. * Array of attributes to getter functions (for serialization of requests)
  226. *
  227. * @return array
  228. */
  229. public static function getters()
  230. {
  231. return self::$getters;
  232. }
  233. /**
  234. * The original name of the model.
  235. *
  236. * @return string
  237. */
  238. public function getModelName()
  239. {
  240. return self::$openAPIModelName;
  241. }
  242. /**
  243. * Associative array for storing property values
  244. *
  245. * @var mixed[]
  246. */
  247. protected $container = [];
  248. /**
  249. * Constructor
  250. *
  251. * @param mixed[]|null $data Associated array of property values
  252. * initializing the model
  253. */
  254. public function __construct(?array $data = null)
  255. {
  256. $this->setIfExists('article_id', $data ?? [], null);
  257. $this->setIfExists('book', $data ?? [], null);
  258. $this->setIfExists('paragraph', $data ?? [], null);
  259. $this->setIfExists('title', $data ?? [], null);
  260. $this->setIfExists('collection', $data ?? [], null);
  261. $this->setIfExists('readers', $data ?? [], null);
  262. $this->setIfExists('records', $data ?? [], null);
  263. }
  264. /**
  265. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  266. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  267. * $this->openAPINullablesSetToNull array
  268. *
  269. * @param string $variableName
  270. * @param array $fields
  271. * @param mixed $defaultValue
  272. */
  273. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  274. {
  275. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  276. $this->openAPINullablesSetToNull[] = $variableName;
  277. }
  278. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  279. }
  280. /**
  281. * Show all the invalid properties with reasons.
  282. *
  283. * @return array invalid properties with reasons
  284. */
  285. public function listInvalidProperties()
  286. {
  287. $invalidProperties = [];
  288. return $invalidProperties;
  289. }
  290. /**
  291. * Validate all the properties in the model
  292. * return true if all passed
  293. *
  294. * @return bool True if all properties are valid
  295. */
  296. public function valid()
  297. {
  298. return count($this->listInvalidProperties()) === 0;
  299. }
  300. /**
  301. * Gets article_id
  302. *
  303. * @return string|null
  304. */
  305. public function getArticleId()
  306. {
  307. return $this->container['article_id'];
  308. }
  309. /**
  310. * Sets article_id
  311. *
  312. * @param string|null $article_id article_id
  313. *
  314. * @return self
  315. */
  316. public function setArticleId($article_id)
  317. {
  318. if (is_null($article_id)) {
  319. throw new \InvalidArgumentException('non-nullable article_id cannot be null');
  320. }
  321. $this->container['article_id'] = $article_id;
  322. return $this;
  323. }
  324. /**
  325. * Gets book
  326. *
  327. * @return int|null
  328. */
  329. public function getBook()
  330. {
  331. return $this->container['book'];
  332. }
  333. /**
  334. * Sets book
  335. *
  336. * @param int|null $book book
  337. *
  338. * @return self
  339. */
  340. public function setBook($book)
  341. {
  342. if (is_null($book)) {
  343. throw new \InvalidArgumentException('non-nullable book cannot be null');
  344. }
  345. $this->container['book'] = $book;
  346. return $this;
  347. }
  348. /**
  349. * Gets paragraph
  350. *
  351. * @return int|null
  352. */
  353. public function getParagraph()
  354. {
  355. return $this->container['paragraph'];
  356. }
  357. /**
  358. * Sets paragraph
  359. *
  360. * @param int|null $paragraph paragraph
  361. *
  362. * @return self
  363. */
  364. public function setParagraph($paragraph)
  365. {
  366. if (is_null($paragraph)) {
  367. throw new \InvalidArgumentException('non-nullable paragraph cannot be null');
  368. }
  369. $this->container['paragraph'] = $paragraph;
  370. return $this;
  371. }
  372. /**
  373. * Gets title
  374. *
  375. * @return string|null
  376. */
  377. public function getTitle()
  378. {
  379. return $this->container['title'];
  380. }
  381. /**
  382. * Sets title
  383. *
  384. * @param string|null $title title
  385. *
  386. * @return self
  387. */
  388. public function setTitle($title)
  389. {
  390. if (is_null($title)) {
  391. throw new \InvalidArgumentException('non-nullable title cannot be null');
  392. }
  393. $this->container['title'] = $title;
  394. return $this;
  395. }
  396. /**
  397. * Gets collection
  398. *
  399. * @return string|null
  400. */
  401. public function getCollection()
  402. {
  403. return $this->container['collection'];
  404. }
  405. /**
  406. * Sets collection
  407. *
  408. * @param string|null $collection collection
  409. *
  410. * @return self
  411. */
  412. public function setCollection($collection)
  413. {
  414. if (is_null($collection)) {
  415. array_push($this->openAPINullablesSetToNull, 'collection');
  416. } else {
  417. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  418. $index = array_search('collection', $nullablesSetToNull);
  419. if ($index !== FALSE) {
  420. unset($nullablesSetToNull[$index]);
  421. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  422. }
  423. }
  424. $this->container['collection'] = $collection;
  425. return $this;
  426. }
  427. /**
  428. * Gets readers
  429. *
  430. * @return int|null
  431. */
  432. public function getReaders()
  433. {
  434. return $this->container['readers'];
  435. }
  436. /**
  437. * Sets readers
  438. *
  439. * @param int|null $readers readers
  440. *
  441. * @return self
  442. */
  443. public function setReaders($readers)
  444. {
  445. if (is_null($readers)) {
  446. throw new \InvalidArgumentException('non-nullable readers cannot be null');
  447. }
  448. $this->container['readers'] = $readers;
  449. return $this;
  450. }
  451. /**
  452. * Gets records
  453. *
  454. * @return int|null
  455. */
  456. public function getRecords()
  457. {
  458. return $this->container['records'];
  459. }
  460. /**
  461. * Sets records
  462. *
  463. * @param int|null $records records
  464. *
  465. * @return self
  466. */
  467. public function setRecords($records)
  468. {
  469. if (is_null($records)) {
  470. throw new \InvalidArgumentException('non-nullable records cannot be null');
  471. }
  472. $this->container['records'] = $records;
  473. return $this;
  474. }
  475. /**
  476. * Returns true if offset exists. False otherwise.
  477. *
  478. * @param integer|string $offset Offset
  479. *
  480. * @return boolean
  481. */
  482. public function offsetExists(mixed $offset): bool
  483. {
  484. return isset($this->container[$offset]);
  485. }
  486. /**
  487. * Gets offset.
  488. *
  489. * @param integer|string $offset Offset
  490. *
  491. * @return mixed|null
  492. */
  493. #[\ReturnTypeWillChange]
  494. public function offsetGet(mixed $offset)
  495. {
  496. return $this->container[$offset] ?? null;
  497. }
  498. /**
  499. * Sets value based on offset.
  500. *
  501. * @param int|null $offset Offset
  502. * @param mixed $value Value to be set
  503. *
  504. * @return void
  505. */
  506. public function offsetSet($offset, $value): void
  507. {
  508. if (is_null($offset)) {
  509. $this->container[] = $value;
  510. } else {
  511. $this->container[$offset] = $value;
  512. }
  513. }
  514. /**
  515. * Unsets offset.
  516. *
  517. * @param integer|string $offset Offset
  518. *
  519. * @return void
  520. */
  521. public function offsetUnset(mixed $offset): void
  522. {
  523. unset($this->container[$offset]);
  524. }
  525. /**
  526. * Serializes the object to a value that can be serialized natively by json_encode().
  527. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  528. *
  529. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  530. * of any type other than a resource.
  531. */
  532. #[\ReturnTypeWillChange]
  533. public function jsonSerialize()
  534. {
  535. return ObjectSerializer::sanitizeForSerialization($this);
  536. }
  537. /**
  538. * Gets the string presentation of the object
  539. *
  540. * @return string
  541. */
  542. public function __toString()
  543. {
  544. return json_encode(
  545. ObjectSerializer::sanitizeForSerialization($this),
  546. JSON_PRETTY_PRINT
  547. );
  548. }
  549. /**
  550. * Gets a header-safe presentation of the object
  551. *
  552. * @return string
  553. */
  554. public function toHeaderValue()
  555. {
  556. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  557. }
  558. }