mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
Use query builder and proper typed result for user search
This commit is contained in:
parent
79d9f779f5
commit
e61c5fc249
3 changed files with 88 additions and 15 deletions
48
src/Data/SteamUser.php
Normal file
48
src/Data/SteamUser.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Demostf\API\Data;
|
||||
|
||||
class SteamUser implements \JsonSerializable {
|
||||
/** @var int */
|
||||
private $id;
|
||||
/** @var string */
|
||||
private $steamId;
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
public function __construct(int $id, string $steamId, string $name) {
|
||||
$this->id = $id;
|
||||
$this->steamId = $steamId;
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getId(): int {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getSteamId(): string {
|
||||
return $this->steamId;
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'steamid' => $this->getSteamId(),
|
||||
'name' => $this->getName()
|
||||
];
|
||||
}
|
||||
|
||||
public static function fromRow(array $row): SteamUser {
|
||||
return new self(
|
||||
(int) $row['id'],
|
||||
$row['steamid'],
|
||||
$row['name']
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue