GetApiV3AdminReadingStats200ResponseDataSummary.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <?php
  2. /**
  3. * GetApiV3AdminReadingStats200ResponseDataSummary
  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. * GetApiV3AdminReadingStats200ResponseDataSummary 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 GetApiV3AdminReadingStats200ResponseDataSummary 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_summary';
  47. /**
  48. * Array of property to type mappings. Used for (de)serialization
  49. *
  50. * @var string[]
  51. */
  52. protected static $openAPITypes = [
  53. 'active_readers' => 'int',
  54. 'chapters_opened' => 'int',
  55. 'reading_seconds' => 'int',
  56. 'reading_users' => 'int',
  57. 'page_views' => 'int',
  58. 'dict_lookups' => 'int'
  59. ];
  60. /**
  61. * Array of property to format mappings. Used for (de)serialization
  62. *
  63. * @var string[]
  64. * @phpstan-var array<string, string|null>
  65. * @psalm-var array<string, string|null>
  66. */
  67. protected static $openAPIFormats = [
  68. 'active_readers' => null,
  69. 'chapters_opened' => null,
  70. 'reading_seconds' => null,
  71. 'reading_users' => null,
  72. 'page_views' => null,
  73. 'dict_lookups' => null
  74. ];
  75. /**
  76. * Array of nullable properties. Used for (de)serialization
  77. *
  78. * @var boolean[]
  79. */
  80. protected static array $openAPINullables = [
  81. 'active_readers' => false,
  82. 'chapters_opened' => false,
  83. 'reading_seconds' => true,
  84. 'reading_users' => true,
  85. 'page_views' => true,
  86. 'dict_lookups' => false
  87. ];
  88. /**
  89. * If a nullable field gets set to null, insert it here
  90. *
  91. * @var boolean[]
  92. */
  93. protected array $openAPINullablesSetToNull = [];
  94. /**
  95. * Array of property to type mappings. Used for (de)serialization
  96. *
  97. * @return array
  98. */
  99. public static function openAPITypes()
  100. {
  101. return self::$openAPITypes;
  102. }
  103. /**
  104. * Array of property to format mappings. Used for (de)serialization
  105. *
  106. * @return array
  107. */
  108. public static function openAPIFormats()
  109. {
  110. return self::$openAPIFormats;
  111. }
  112. /**
  113. * Array of nullable properties
  114. *
  115. * @return array
  116. */
  117. protected static function openAPINullables(): array
  118. {
  119. return self::$openAPINullables;
  120. }
  121. /**
  122. * Array of nullable field names deliberately set to null
  123. *
  124. * @return boolean[]
  125. */
  126. private function getOpenAPINullablesSetToNull(): array
  127. {
  128. return $this->openAPINullablesSetToNull;
  129. }
  130. /**
  131. * Setter - Array of nullable field names deliberately set to null
  132. *
  133. * @param boolean[] $openAPINullablesSetToNull
  134. */
  135. private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
  136. {
  137. $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
  138. }
  139. /**
  140. * Checks if a property is nullable
  141. *
  142. * @param string $property
  143. * @return bool
  144. */
  145. public static function isNullable(string $property): bool
  146. {
  147. return self::openAPINullables()[$property] ?? false;
  148. }
  149. /**
  150. * Checks if a nullable property is set to null.
  151. *
  152. * @param string $property
  153. * @return bool
  154. */
  155. public function isNullableSetToNull(string $property): bool
  156. {
  157. return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
  158. }
  159. /**
  160. * Array of attributes where the key is the local name,
  161. * and the value is the original name
  162. *
  163. * @var string[]
  164. */
  165. protected static $attributeMap = [
  166. 'active_readers' => 'active_readers',
  167. 'chapters_opened' => 'chapters_opened',
  168. 'reading_seconds' => 'reading_seconds',
  169. 'reading_users' => 'reading_users',
  170. 'page_views' => 'page_views',
  171. 'dict_lookups' => 'dict_lookups'
  172. ];
  173. /**
  174. * Array of attributes to setter functions (for deserialization of responses)
  175. *
  176. * @var string[]
  177. */
  178. protected static $setters = [
  179. 'active_readers' => 'setActiveReaders',
  180. 'chapters_opened' => 'setChaptersOpened',
  181. 'reading_seconds' => 'setReadingSeconds',
  182. 'reading_users' => 'setReadingUsers',
  183. 'page_views' => 'setPageViews',
  184. 'dict_lookups' => 'setDictLookups'
  185. ];
  186. /**
  187. * Array of attributes to getter functions (for serialization of requests)
  188. *
  189. * @var string[]
  190. */
  191. protected static $getters = [
  192. 'active_readers' => 'getActiveReaders',
  193. 'chapters_opened' => 'getChaptersOpened',
  194. 'reading_seconds' => 'getReadingSeconds',
  195. 'reading_users' => 'getReadingUsers',
  196. 'page_views' => 'getPageViews',
  197. 'dict_lookups' => 'getDictLookups'
  198. ];
  199. /**
  200. * Array of attributes where the key is the local name,
  201. * and the value is the original name
  202. *
  203. * @return array
  204. */
  205. public static function attributeMap()
  206. {
  207. return self::$attributeMap;
  208. }
  209. /**
  210. * Array of attributes to setter functions (for deserialization of responses)
  211. *
  212. * @return array
  213. */
  214. public static function setters()
  215. {
  216. return self::$setters;
  217. }
  218. /**
  219. * Array of attributes to getter functions (for serialization of requests)
  220. *
  221. * @return array
  222. */
  223. public static function getters()
  224. {
  225. return self::$getters;
  226. }
  227. /**
  228. * The original name of the model.
  229. *
  230. * @return string
  231. */
  232. public function getModelName()
  233. {
  234. return self::$openAPIModelName;
  235. }
  236. /**
  237. * Associative array for storing property values
  238. *
  239. * @var mixed[]
  240. */
  241. protected $container = [];
  242. /**
  243. * Constructor
  244. *
  245. * @param mixed[]|null $data Associated array of property values
  246. * initializing the model
  247. */
  248. public function __construct(?array $data = null)
  249. {
  250. $this->setIfExists('active_readers', $data ?? [], null);
  251. $this->setIfExists('chapters_opened', $data ?? [], null);
  252. $this->setIfExists('reading_seconds', $data ?? [], null);
  253. $this->setIfExists('reading_users', $data ?? [], null);
  254. $this->setIfExists('page_views', $data ?? [], null);
  255. $this->setIfExists('dict_lookups', $data ?? [], null);
  256. }
  257. /**
  258. * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
  259. * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
  260. * $this->openAPINullablesSetToNull array
  261. *
  262. * @param string $variableName
  263. * @param array $fields
  264. * @param mixed $defaultValue
  265. */
  266. private function setIfExists(string $variableName, array $fields, $defaultValue): void
  267. {
  268. if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
  269. $this->openAPINullablesSetToNull[] = $variableName;
  270. }
  271. $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
  272. }
  273. /**
  274. * Show all the invalid properties with reasons.
  275. *
  276. * @return array invalid properties with reasons
  277. */
  278. public function listInvalidProperties()
  279. {
  280. $invalidProperties = [];
  281. return $invalidProperties;
  282. }
  283. /**
  284. * Validate all the properties in the model
  285. * return true if all passed
  286. *
  287. * @return bool True if all properties are valid
  288. */
  289. public function valid()
  290. {
  291. return count($this->listInvalidProperties()) === 0;
  292. }
  293. /**
  294. * Gets active_readers
  295. *
  296. * @return int|null
  297. */
  298. public function getActiveReaders()
  299. {
  300. return $this->container['active_readers'];
  301. }
  302. /**
  303. * Sets active_readers
  304. *
  305. * @param int|null $active_readers active_readers
  306. *
  307. * @return self
  308. */
  309. public function setActiveReaders($active_readers)
  310. {
  311. if (is_null($active_readers)) {
  312. throw new \InvalidArgumentException('non-nullable active_readers cannot be null');
  313. }
  314. $this->container['active_readers'] = $active_readers;
  315. return $this;
  316. }
  317. /**
  318. * Gets chapters_opened
  319. *
  320. * @return int|null
  321. */
  322. public function getChaptersOpened()
  323. {
  324. return $this->container['chapters_opened'];
  325. }
  326. /**
  327. * Sets chapters_opened
  328. *
  329. * @param int|null $chapters_opened chapters_opened
  330. *
  331. * @return self
  332. */
  333. public function setChaptersOpened($chapters_opened)
  334. {
  335. if (is_null($chapters_opened)) {
  336. throw new \InvalidArgumentException('non-nullable chapters_opened cannot be null');
  337. }
  338. $this->container['chapters_opened'] = $chapters_opened;
  339. return $this;
  340. }
  341. /**
  342. * Gets reading_seconds
  343. *
  344. * @return int|null
  345. */
  346. public function getReadingSeconds()
  347. {
  348. return $this->container['reading_seconds'];
  349. }
  350. /**
  351. * Sets reading_seconds
  352. *
  353. * @param int|null $reading_seconds reading_seconds
  354. *
  355. * @return self
  356. */
  357. public function setReadingSeconds($reading_seconds)
  358. {
  359. if (is_null($reading_seconds)) {
  360. array_push($this->openAPINullablesSetToNull, 'reading_seconds');
  361. } else {
  362. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  363. $index = array_search('reading_seconds', $nullablesSetToNull);
  364. if ($index !== FALSE) {
  365. unset($nullablesSetToNull[$index]);
  366. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  367. }
  368. }
  369. $this->container['reading_seconds'] = $reading_seconds;
  370. return $this;
  371. }
  372. /**
  373. * Gets reading_users
  374. *
  375. * @return int|null
  376. */
  377. public function getReadingUsers()
  378. {
  379. return $this->container['reading_users'];
  380. }
  381. /**
  382. * Sets reading_users
  383. *
  384. * @param int|null $reading_users reading_users
  385. *
  386. * @return self
  387. */
  388. public function setReadingUsers($reading_users)
  389. {
  390. if (is_null($reading_users)) {
  391. array_push($this->openAPINullablesSetToNull, 'reading_users');
  392. } else {
  393. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  394. $index = array_search('reading_users', $nullablesSetToNull);
  395. if ($index !== FALSE) {
  396. unset($nullablesSetToNull[$index]);
  397. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  398. }
  399. }
  400. $this->container['reading_users'] = $reading_users;
  401. return $this;
  402. }
  403. /**
  404. * Gets page_views
  405. *
  406. * @return int|null
  407. */
  408. public function getPageViews()
  409. {
  410. return $this->container['page_views'];
  411. }
  412. /**
  413. * Sets page_views
  414. *
  415. * @param int|null $page_views page_views
  416. *
  417. * @return self
  418. */
  419. public function setPageViews($page_views)
  420. {
  421. if (is_null($page_views)) {
  422. array_push($this->openAPINullablesSetToNull, 'page_views');
  423. } else {
  424. $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
  425. $index = array_search('page_views', $nullablesSetToNull);
  426. if ($index !== FALSE) {
  427. unset($nullablesSetToNull[$index]);
  428. $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
  429. }
  430. }
  431. $this->container['page_views'] = $page_views;
  432. return $this;
  433. }
  434. /**
  435. * Gets dict_lookups
  436. *
  437. * @return int|null
  438. */
  439. public function getDictLookups()
  440. {
  441. return $this->container['dict_lookups'];
  442. }
  443. /**
  444. * Sets dict_lookups
  445. *
  446. * @param int|null $dict_lookups dict_lookups
  447. *
  448. * @return self
  449. */
  450. public function setDictLookups($dict_lookups)
  451. {
  452. if (is_null($dict_lookups)) {
  453. throw new \InvalidArgumentException('non-nullable dict_lookups cannot be null');
  454. }
  455. $this->container['dict_lookups'] = $dict_lookups;
  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. }