PaginationMeta.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <?php
  2. /**
  3. * PaginationMeta
  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.8
  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. * PaginationMeta Class Doc Comment
  31. *
  32. * @category Class
  33. * @description v3 列表接口的分页信息,由 Laravel paginator 生成。 刻意不含 links / path:那些是 APP_URL 拼出的绝对地址,反代下会拼错,前端也用不到。 手工分页的接口会附加自己的字段(如 has_more / first_para / page_size)。
  34. * @package WikipaliApi
  35. * @author OpenAPI Generator team
  36. * @link https://openapi-generator.tech
  37. * @implements \ArrayAccess<string, mixed>
  38. */
  39. class PaginationMeta 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 = 'PaginationMeta';
  48. /**
  49. * Array of property to type mappings. Used for (de)serialization
  50. *
  51. * @var string[]
  52. */
  53. protected static $openAPITypes = [
  54. 'current_page' => 'int',
  55. 'per_page' => 'int',
  56. 'total' => 'int',
  57. 'last_page' => 'int',
  58. 'from' => 'int',
  59. 'to' => '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. 'current_page' => null,
  70. 'per_page' => null,
  71. 'total' => null,
  72. 'last_page' => null,
  73. 'from' => null,
  74. 'to' => null
  75. ];
  76. /**
  77. * Array of nullable properties. Used for (de)serialization
  78. *
  79. * @var boolean[]
  80. */
  81. protected static array $openAPINullables = [
  82. 'current_page' => false,
  83. 'per_page' => false,
  84. 'total' => false,
  85. 'last_page' => false,
  86. 'from' => true,
  87. 'to' => true
  88. ];
  89. /**
  90. * If a nullable field gets set to null, insert it here
  91. *
  92. * @var boolean[]
  93. */
  94. protected array $openAPINullablesSetToNull = [];
  95. /**
  96. * Array of property to type mappings. Used for (de)serialization
  97. *
  98. * @return array
  99. */
  100. public static function openAPITypes()
  101. {
  102. return self::$openAPITypes;
  103. }
  104. /**
  105. * Array of property to format mappings. Used for (de)serialization
  106. *
  107. * @return array
  108. */
  109. public static function openAPIFormats()
  110. {
  111. return self::$openAPIFormats;
  112. }
  113. /**
  114. * Array of nullable properties
  115. *
  116. * @return array
  117. */
  118. protected static function openAPINullables(): array
  119. {
  120. return self::$openAPINullables;
  121. }
  122. /**
  123. * Array of nullable field names deliberately set to null
  124. *
  125. * @return boolean[]
  126. */
  127. private function getOpenAPINullablesSetToNull(): array
  128. {
  129. return $this->openAPINullablesSetToNull;
  130. }
  131. /**
  132. * Setter - Array of nullable field names deliberately set to null
  133. *
  134. * @param boolean[] $openAPINullablesSetToNull
  135. */
  136. private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
  137. {
  138. $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
  139. }
  140. /**
  141. * Checks if a property is nullable
  142. *
  143. * @param string $property
  144. * @return bool
  145. */
  146. public static function isNullable(string $property): bool
  147. {
  148. return self::openAPINullables()[$property] ?? false;
  149. }
  150. /**
  151. * Checks if a nullable property is set to null.
  152. *
  153. * @param string $property
  154. * @return bool
  155. */
  156. public function isNullableSetToNull(string $property): bool
  157. {
  158. return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
  159. }
  160. /**
  161. * Array of attributes where the key is the local name,
  162. * and the value is the original name
  163. *
  164. * @var string[]
  165. */
  166. protected static $attributeMap = [
  167. 'current_page' => 'current_page',
  168. 'per_page' => 'per_page',
  169. 'total' => 'total',
  170. 'last_page' => 'last_page',
  171. 'from' => 'from',
  172. 'to' => 'to'
  173. ];
  174. /**
  175. * Array of attributes to setter functions (for deserialization of responses)
  176. *
  177. * @var string[]
  178. */
  179. protected static $setters = [
  180. 'current_page' => 'setCurrentPage',
  181. 'per_page' => 'setPerPage',
  182. 'total' => 'setTotal',
  183. 'last_page' => 'setLastPage',
  184. 'from' => 'setFrom',
  185. 'to' => 'setTo'
  186. ];
  187. /**
  188. * Array of attributes to getter functions (for serialization of requests)
  189. *
  190. * @var string[]
  191. */
  192. protected static $getters = [
  193. 'current_page' => 'getCurrentPage',
  194. 'per_page' => 'getPerPage',
  195. 'total' => 'getTotal',
  196. 'last_page' => 'getLastPage',
  197. 'from' => 'getFrom',
  198. 'to' => 'getTo'
  199. ];
  200. /**
  201. * Array of attributes where the key is the local name,
  202. * and the value is the original name
  203. *
  204. * @return array
  205. */
  206. public static function attributeMap()
  207. {
  208. return self::$attributeMap;
  209. }
  210. /**
  211. * Array of attributes to setter functions (for deserialization of responses)
  212. *
  213. * @return array
  214. */
  215. public static function setters()
  216. {
  217. return self::$setters;
  218. }
  219. /**
  220. * Array of attributes to getter functions (for serialization of requests)
  221. *
  222. * @return array
  223. */
  224. public static function getters()
  225. {
  226. return self::$getters;
  227. }
  228. /**
  229. * The original name of the model.
  230. *
  231. * @return string
  232. */
  233. public function getModelName()
  234. {
  235. return self::$openAPIModelName;
  236. }
  237. /**
  238. * Associative array for storing property values
  239. *
  240. * @var mixed[]
  241. */
  242. protected $container = [];
  243. /**
  244. * Constructor
  245. *
  246. * @param mixed[]|null $data Associated array of property values
  247. * initializing the model
  248. */
  249. public function __construct(?array $data = null)
  250. {
  251. $this->setIfExists('current_page', $data ?? [], null);
  252. $this->setIfExists('per_page', $data ?? [], null);
  253. $this->setIfExists('total', $data ?? [], null);
  254. $this->setIfExists('last_page', $data ?? [], null);
  255. $this->setIfExists('from', $data ?? [], null);
  256. $this->setIfExists('to', $data ?? [], null);
  257. }
  258. /**
  259. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  260. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  261. * $this->openAPINullablesSetToNull array
  262. *
  263. * @param string $variableName
  264. * @param array $fields
  265. * @param mixed $defaultValue
  266. */
  267. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  268. {
  269. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  270. $this->openAPINullablesSetToNull[] = $variableName;
  271. }
  272. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  273. }
  274. /**
  275. * Show all the invalid properties with reasons.
  276. *
  277. * @return array invalid properties with reasons
  278. */
  279. public function listInvalidProperties()
  280. {
  281. $invalidProperties = [];
  282. if ($this->container['current_page'] === null) {
  283. $invalidProperties[] = "'current_page' can't be null";
  284. }
  285. if ($this->container['total'] === null) {
  286. $invalidProperties[] = "'total' can't be null";
  287. }
  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 current_page
  302. *
  303. * @return int
  304. */
  305. public function getCurrentPage()
  306. {
  307. return $this->container['current_page'];
  308. }
  309. /**
  310. * Sets current_page
  311. *
  312. * @param int $current_page current_page
  313. *
  314. * @return self
  315. */
  316. public function setCurrentPage($current_page)
  317. {
  318. if (is_null($current_page)) {
  319. throw new \InvalidArgumentException('non-nullable current_page cannot be null');
  320. }
  321. $this->container['current_page'] = $current_page;
  322. return $this;
  323. }
  324. /**
  325. * Gets per_page
  326. *
  327. * @return int|null
  328. */
  329. public function getPerPage()
  330. {
  331. return $this->container['per_page'];
  332. }
  333. /**
  334. * Sets per_page
  335. *
  336. * @param int|null $per_page per_page
  337. *
  338. * @return self
  339. */
  340. public function setPerPage($per_page)
  341. {
  342. if (is_null($per_page)) {
  343. throw new \InvalidArgumentException('non-nullable per_page cannot be null');
  344. }
  345. $this->container['per_page'] = $per_page;
  346. return $this;
  347. }
  348. /**
  349. * Gets total
  350. *
  351. * @return int
  352. */
  353. public function getTotal()
  354. {
  355. return $this->container['total'];
  356. }
  357. /**
  358. * Sets total
  359. *
  360. * @param int $total total
  361. *
  362. * @return self
  363. */
  364. public function setTotal($total)
  365. {
  366. if (is_null($total)) {
  367. throw new \InvalidArgumentException('non-nullable total cannot be null');
  368. }
  369. $this->container['total'] = $total;
  370. return $this;
  371. }
  372. /**
  373. * Gets last_page
  374. *
  375. * @return int|null
  376. */
  377. public function getLastPage()
  378. {
  379. return $this->container['last_page'];
  380. }
  381. /**
  382. * Sets last_page
  383. *
  384. * @param int|null $last_page last_page
  385. *
  386. * @return self
  387. */
  388. public function setLastPage($last_page)
  389. {
  390. if (is_null($last_page)) {
  391. throw new \InvalidArgumentException('non-nullable last_page cannot be null');
  392. }
  393. $this->container['last_page'] = $last_page;
  394. return $this;
  395. }
  396. /**
  397. * Gets from
  398. *
  399. * @return int|null
  400. */
  401. public function getFrom()
  402. {
  403. return $this->container['from'];
  404. }
  405. /**
  406. * Sets from
  407. *
  408. * @param int|null $from from
  409. *
  410. * @return self
  411. */
  412. public function setFrom($from)
  413. {
  414. if (is_null($from)) {
  415. array_push($this->openAPINullablesSetToNull, 'from');
  416. } else {
  417. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  418. $index = array_search('from', $nullablesSetToNull);
  419. if ($index !== FALSE) {
  420. unset($nullablesSetToNull[$index]);
  421. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  422. }
  423. }
  424. $this->container['from'] = $from;
  425. return $this;
  426. }
  427. /**
  428. * Gets to
  429. *
  430. * @return int|null
  431. */
  432. public function getTo()
  433. {
  434. return $this->container['to'];
  435. }
  436. /**
  437. * Sets to
  438. *
  439. * @param int|null $to to
  440. *
  441. * @return self
  442. */
  443. public function setTo($to)
  444. {
  445. if (is_null($to)) {
  446. array_push($this->openAPINullablesSetToNull, 'to');
  447. } else {
  448. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  449. $index = array_search('to', $nullablesSetToNull);
  450. if ($index !== FALSE) {
  451. unset($nullablesSetToNull[$index]);
  452. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  453. }
  454. }
  455. $this->container['to'] = $to;
  456. return $this;
  457. }
  458. /**
  459. * Returns true if offset exists. False otherwise.
  460. *
  461. * @param integer|string $offset Offset
  462. *
  463. * @return boolean
  464. */
  465. public function offsetExists(mixed $offset): bool
  466. {
  467. return isset($this->container[$offset]);
  468. }
  469. /**
  470. * Gets offset.
  471. *
  472. * @param integer|string $offset Offset
  473. *
  474. * @return mixed|null
  475. */
  476. #[\ReturnTypeWillChange]
  477. public function offsetGet(mixed $offset)
  478. {
  479. return $this->container[$offset] ?? null;
  480. }
  481. /**
  482. * Sets value based on offset.
  483. *
  484. * @param int|null $offset Offset
  485. * @param mixed $value Value to be set
  486. *
  487. * @return void
  488. */
  489. public function offsetSet($offset, $value): void
  490. {
  491. if (is_null($offset)) {
  492. $this->container[] = $value;
  493. } else {
  494. $this->container[$offset] = $value;
  495. }
  496. }
  497. /**
  498. * Unsets offset.
  499. *
  500. * @param integer|string $offset Offset
  501. *
  502. * @return void
  503. */
  504. public function offsetUnset(mixed $offset): void
  505. {
  506. unset($this->container[$offset]);
  507. }
  508. /**
  509. * Serializes the object to a value that can be serialized natively by json_encode().
  510. * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
  511. *
  512. * @return mixed Returns data which can be serialized by json_encode(), which is a value
  513. * of any type other than a resource.
  514. */
  515. #[\ReturnTypeWillChange]
  516. public function jsonSerialize()
  517. {
  518. return ObjectSerializer::sanitizeForSerialization($this);
  519. }
  520. /**
  521. * Gets the string presentation of the object
  522. *
  523. * @return string
  524. */
  525. public function __toString()
  526. {
  527. return json_encode(
  528. ObjectSerializer::sanitizeForSerialization($this),
  529. JSON_PRETTY_PRINT
  530. );
  531. }
  532. /**
  533. * Gets a header-safe presentation of the object
  534. *
  535. * @return string
  536. */
  537. public function toHeaderValue()
  538. {
  539. return json_encode(ObjectSerializer::sanitizeForSerialization($this));
  540. }
  541. }