GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — xmlvalid-php/src/Model/Usage.php at main · xmlvalid/xmlvalid-php

Expand file tree

/

Usage.php

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
54 lines (47 loc) · 1.91 KB
/

Usage.php

Copy path

File metadata and controls

54 lines (47 loc) · 1.91 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
declare(strict_types=1);
namespace Xmlvalid\Model;
use DateTimeImmutable;
/** The account's plan, the API validations used this month, test key validations used today and the limits. */
final class Usage
{
public function __construct(
/** free or pro. */
public readonly string $plan,
public readonly ?DateTimeImmutable $periodStart,
/** When the count resets (the 1st of next month, UTC). */
public readonly ?DateTimeImmutable $resetAt,
public readonly int $used,
public readonly int $limit,
public readonly int $maxFileBytes,
public readonly int $requestsPerMinute,
/** Validations made today (UTC) with test keys, counted apart from the month's. */
public readonly int $testUsed = 0,
public readonly int $testLimit = 0,
public readonly ?DateTimeImmutable $testResetAt = null,
) {}
/** @param array<string, mixed> $data */
public static function fromArray(array $data): self
{
$period = Data::object($data, 'period') ?? [];
$validations = Data::object($data, 'validations') ?? [];
$limits = Data::object($data, 'limits') ?? [];
$test = Data::object($data, 'test_validations') ?? [];
return new self(
plan: Data::string($data, 'plan'),
periodStart: Data::date($period, 'start'),
resetAt: Data::date($period, 'reset_at'),
used: Data::int($validations, 'used'),
limit: Data::int($validations, 'limit'),
maxFileBytes: Data::int($limits, 'max_file_bytes'),
requestsPerMinute: Data::int($limits, 'requests_per_minute'),
testUsed: Data::int($test, 'used'),
testLimit: Data::int($test, 'limit'),
testResetAt: Data::date($test, 'reset_at'),
);
}
public function remaining(): int
{
return max(0, $this->limit - $this->used);
}
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.