Compare commits

..

2 commits

Author SHA1 Message Date
324fe21d73 Use attributes for JSON encoding. 2024-09-30 17:38:08 +00:00
153abde3a2 Updated libraries. 2024-09-30 17:37:41 +00:00
3 changed files with 87 additions and 70 deletions

62
composer.lock generated
View file

@ -457,11 +457,11 @@
}, },
{ {
"name": "flashwave/index", "name": "flashwave/index",
"version": "v0.2408.401738", "version": "v0.2408.611934",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://patchii.net/flash/index.git", "url": "https://patchii.net/flash/index.git",
"reference": "1339de93bf08d773207468227f7d134d41e68688" "reference": "2217c8c3de8e4ec8d7f9ec0f37078dbc2183d14e"
}, },
"require": { "require": {
"ext-mbstring": "*", "ext-mbstring": "*",
@ -495,7 +495,7 @@
], ],
"description": "Composer package for the common library for my projects.", "description": "Composer package for the common library for my projects.",
"homepage": "https://railgun.sh/index", "homepage": "https://railgun.sh/index",
"time": "2024-09-13T15:38:44+00:00" "time": "2024-09-30T17:34:51+00:00"
}, },
{ {
"name": "flashwave/sasae", "name": "flashwave/sasae",
@ -752,16 +752,16 @@
}, },
{ {
"name": "matomo/device-detector", "name": "matomo/device-detector",
"version": "6.4.0", "version": "6.4.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/matomo-org/device-detector.git", "url": "https://github.com/matomo-org/device-detector.git",
"reference": "05dca429cfe7b6a59947a0d449dbeb60cddc02f2" "reference": "0d364e0dd6c177da3c24cd4049178026324fd7ac"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/matomo-org/device-detector/zipball/05dca429cfe7b6a59947a0d449dbeb60cddc02f2", "url": "https://api.github.com/repos/matomo-org/device-detector/zipball/0d364e0dd6c177da3c24cd4049178026324fd7ac",
"reference": "05dca429cfe7b6a59947a0d449dbeb60cddc02f2", "reference": "0d364e0dd6c177da3c24cd4049178026324fd7ac",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -817,7 +817,7 @@
"source": "https://github.com/matomo-org/matomo", "source": "https://github.com/matomo-org/matomo",
"wiki": "https://dev.matomo.org/" "wiki": "https://dev.matomo.org/"
}, },
"time": "2024-09-10T08:27:24+00:00" "time": "2024-09-24T13:50:04+00:00"
}, },
{ {
"name": "mustangostang/spyc", "name": "mustangostang/spyc",
@ -1775,16 +1775,16 @@
}, },
{ {
"name": "symfony/mailer", "name": "symfony/mailer",
"version": "v6.4.9", "version": "v6.4.12",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/mailer.git", "url": "https://github.com/symfony/mailer.git",
"reference": "e2d56f180f5b8c5e7c0fbea872bb1f529b6d6d45" "reference": "b6a25408c569ae2366b3f663a4edad19420a9c26"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/mailer/zipball/e2d56f180f5b8c5e7c0fbea872bb1f529b6d6d45", "url": "https://api.github.com/repos/symfony/mailer/zipball/b6a25408c569ae2366b3f663a4edad19420a9c26",
"reference": "e2d56f180f5b8c5e7c0fbea872bb1f529b6d6d45", "reference": "b6a25408c569ae2366b3f663a4edad19420a9c26",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1835,7 +1835,7 @@
"description": "Helps sending emails", "description": "Helps sending emails",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/mailer/tree/v6.4.9" "source": "https://github.com/symfony/mailer/tree/v6.4.12"
}, },
"funding": [ "funding": [
{ {
@ -1851,20 +1851,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-06-28T07:59:05+00:00" "time": "2024-09-08T12:30:05+00:00"
}, },
{ {
"name": "symfony/mime", "name": "symfony/mime",
"version": "v7.1.4", "version": "v7.1.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/mime.git", "url": "https://github.com/symfony/mime.git",
"reference": "ccaa6c2503db867f472a587291e764d6a1e58758" "reference": "711d2e167e8ce65b05aea6b258c449671cdd38ff"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/mime/zipball/ccaa6c2503db867f472a587291e764d6a1e58758", "url": "https://api.github.com/repos/symfony/mime/zipball/711d2e167e8ce65b05aea6b258c449671cdd38ff",
"reference": "ccaa6c2503db867f472a587291e764d6a1e58758", "reference": "711d2e167e8ce65b05aea6b258c449671cdd38ff",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1919,7 +1919,7 @@
"mime-type" "mime-type"
], ],
"support": { "support": {
"source": "https://github.com/symfony/mime/tree/v7.1.4" "source": "https://github.com/symfony/mime/tree/v7.1.5"
}, },
"funding": [ "funding": [
{ {
@ -1935,7 +1935,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-08-13T14:28:19+00:00" "time": "2024-09-20T08:28:38+00:00"
}, },
{ {
"name": "symfony/options-resolver", "name": "symfony/options-resolver",
@ -2564,16 +2564,16 @@
}, },
{ {
"name": "symfony/translation", "name": "symfony/translation",
"version": "v7.1.3", "version": "v7.1.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/translation.git", "url": "https://github.com/symfony/translation.git",
"reference": "8d5e50c813ba2859a6dfc99a0765c550507934a1" "reference": "235535e3f84f3dfbdbde0208ede6ca75c3a489ea"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/8d5e50c813ba2859a6dfc99a0765c550507934a1", "url": "https://api.github.com/repos/symfony/translation/zipball/235535e3f84f3dfbdbde0208ede6ca75c3a489ea",
"reference": "8d5e50c813ba2859a6dfc99a0765c550507934a1", "reference": "235535e3f84f3dfbdbde0208ede6ca75c3a489ea",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2638,7 +2638,7 @@
"description": "Provides tools to internationalize your application", "description": "Provides tools to internationalize your application",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/translation/tree/v7.1.3" "source": "https://github.com/symfony/translation/tree/v7.1.5"
}, },
"funding": [ "funding": [
{ {
@ -2654,7 +2654,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-07-26T12:41:01+00:00" "time": "2024-09-16T06:30:38+00:00"
}, },
{ {
"name": "symfony/translation-contracts", "name": "symfony/translation-contracts",
@ -2885,16 +2885,16 @@
"packages-dev": [ "packages-dev": [
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.12.3", "version": "1.12.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "0fcbf194ab63d8159bb70d9aa3e1350051632009" "reference": "7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/0fcbf194ab63d8159bb70d9aa3e1350051632009", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17",
"reference": "0fcbf194ab63d8159bb70d9aa3e1350051632009", "reference": "7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2939,7 +2939,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-09-09T08:10:35+00:00" "time": "2024-09-26T12:45:22+00:00"
} }
], ],
"aliases": [], "aliases": [],

38
package-lock.json generated
View file

@ -357,9 +357,9 @@
"license": "ISC" "license": "ISC"
}, },
"node_modules/browserslist": { "node_modules/browserslist": {
"version": "4.23.3", "version": "4.24.0",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.3.tgz", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.0.tgz",
"integrity": "sha512-btwCFJVjI4YWDNfau8RhZ+B1Q/VLoUITrm3RlP6y1tYGWIOa+InuYiRGXUBXo8nA1qKmHMyLB/iVQg5TT4eFoA==", "integrity": "sha512-Rmb62sR1Zpjql25eSanFGEhAxcFwfA1K0GuQcLoaJBAcENegrQut3hYdhXFF1obQfiDyqIW/cLM5HSJ/9k884A==",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",
@ -376,8 +376,8 @@
], ],
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"caniuse-lite": "^1.0.30001646", "caniuse-lite": "^1.0.30001663",
"electron-to-chromium": "^1.5.4", "electron-to-chromium": "^1.5.28",
"node-releases": "^2.0.18", "node-releases": "^2.0.18",
"update-browserslist-db": "^1.1.0" "update-browserslist-db": "^1.1.0"
}, },
@ -417,9 +417,9 @@
} }
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001660", "version": "1.0.30001664",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001660.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001664.tgz",
"integrity": "sha512-GacvNTTuATm26qC74pt+ad1fW15mlQ/zuTzzY1ZoIzECTP8HURDfF43kNxPgf7H1jmelCBQTTbBNxdSXOA7Bqg==", "integrity": "sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g==",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",
@ -703,9 +703,9 @@
} }
}, },
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.5.23", "version": "1.5.29",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.23.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.29.tgz",
"integrity": "sha512-mBhODedOXg4v5QWwl21DjM5amzjmI1zw9EPrPK/5Wx7C8jt33bpZNrC7OhHUG3pxRtbLpr3W2dXT+Ph1SsfRZA==", "integrity": "sha512-PF8n2AlIhCKXQ+gTpiJi0VhcHDb69kYX4MtCiivctc2QD3XuNZ/XIOlbGzt7WAjjEev0TtaH6Cu3arZExm5DOw==",
"license": "ISC" "license": "ISC"
}, },
"node_modules/entities": { "node_modules/entities": {
@ -1429,9 +1429,9 @@
} }
}, },
"node_modules/terser": { "node_modules/terser": {
"version": "5.32.0", "version": "5.34.1",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.32.0.tgz", "resolved": "https://registry.npmjs.org/terser/-/terser-5.34.1.tgz",
"integrity": "sha512-v3Gtw3IzpBJ0ugkxEX8U0W6+TnPKRRCWGh1jC/iM/e3Ki5+qvO1L1EAZ56bZasc64aXHwRHNIQEzm6//i5cemQ==", "integrity": "sha512-FsJZ7iZLd/BXkz+4xrRTGJ26o/6VTjQytUk8b8OxkwcD2I+79VPJlz7qss1+zE7h8GNIScFqXcDyJ/KqBYZFVA==",
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"dependencies": { "dependencies": {
"@jridgewell/source-map": "^0.3.3", "@jridgewell/source-map": "^0.3.3",
@ -1459,9 +1459,9 @@
"license": "0BSD" "license": "0BSD"
}, },
"node_modules/update-browserslist-db": { "node_modules/update-browserslist-db": {
"version": "1.1.0", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz",
"integrity": "sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==", "integrity": "sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A==",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",
@ -1478,8 +1478,8 @@
], ],
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"escalade": "^3.1.2", "escalade": "^3.2.0",
"picocolors": "^1.0.1" "picocolors": "^1.1.0"
}, },
"bin": { "bin": {
"update-browserslist-db": "cli.js" "update-browserslist-db": "cli.js"

View file

@ -5,10 +5,12 @@ use stdClass;
use JsonSerializable; use JsonSerializable;
use RuntimeException; use RuntimeException;
use Stringable; use Stringable;
use DeviceDetector\ClientHints; use DeviceDetector\{ClientHints,DeviceDetector};
use DeviceDetector\DeviceDetector; use Index\Json\{JsonProperty,JsonSerializableTrait};
class ClientInfo implements Stringable, JsonSerializable { class ClientInfo implements Stringable, JsonSerializable {
use JsonSerializableTrait;
private const SERIALIZE_VERSION = 1; private const SERIALIZE_VERSION = 1;
public function __construct( public function __construct(
@ -19,6 +21,39 @@ class ClientInfo implements Stringable, JsonSerializable {
private string $modelName private string $modelName
) {} ) {}
#[JsonProperty('version')]
public function getVersion(): int {
return self::SERIALIZE_VERSION;
}
#[JsonProperty('bot')]
public function getBotInfo(): bool|array|null {
if($this->botInfo === true || is_array($this->botInfo))
return $this->botInfo;
return null;
}
#[JsonProperty('client')]
public function getClientInfo(): ?array {
return $this->clientInfo;
}
#[JsonProperty('os')]
public function getOsInfo(): ?array {
return $this->osInfo;
}
#[JsonProperty('vendor', omitIfValue: '')]
public function getVendorName(): string {
return $this->brandName;
}
#[JsonProperty('model', omitIfValue: '')]
public function getModelName(): string {
return $this->modelName;
}
public function __toString(): string { public function __toString(): string {
if($this->botInfo === true || is_array($this->botInfo)) { if($this->botInfo === true || is_array($this->botInfo)) {
if($this->botInfo === true) if($this->botInfo === true)
@ -64,24 +99,6 @@ class ClientInfo implements Stringable, JsonSerializable {
return json_encode($this); return json_encode($this);
} }
public function jsonSerialize(): mixed {
$data = new stdClass;
$data->version = self::SERIALIZE_VERSION;
if($this->botInfo === true || is_array($this->botInfo))
$data->bot = $this->botInfo;
if($this->clientInfo !== null)
$data->client = $this->clientInfo;
if($this->osInfo !== null)
$data->os = $this->osInfo;
if($this->brandName !== '')
$data->vendor = $this->brandName;
if($this->modelName !== '')
$data->model = $this->modelName;
return $data;
}
public static function decode(string $encoded): self { public static function decode(string $encoded): self {
$data = json_decode($encoded, true); $data = json_decode($encoded, true);
$version = $data['version'] ?? 0; $version = $data['version'] ?? 0;