mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-04 10:24:07 +02:00
fmt, typings, typos
This commit is contained in:
parent
eb997b5ba2
commit
7de4c35ab4
34 changed files with 644 additions and 1048 deletions
|
|
@ -56,10 +56,10 @@ class DemoListProvider extends BaseProvider {
|
|||
$query->select('p.demo_id')
|
||||
->from('players', 'p');
|
||||
|
||||
if (\count($userIds) != count($players)) {
|
||||
if (\count($userIds) != \count($players)) {
|
||||
// one of more user ids don't have any demos
|
||||
return [];
|
||||
} else if (\count($userIds) > 1) {
|
||||
} elseif (\count($userIds) > 1) {
|
||||
$query->where($query->expr()->in('user_id',
|
||||
$query->createNamedParameter($userIds, Connection::PARAM_INT_ARRAY)))
|
||||
->groupBy('demo_id')
|
||||
|
|
@ -117,11 +117,11 @@ class DemoListProvider extends BaseProvider {
|
|||
}
|
||||
if (isset($where['before'])) {
|
||||
$query->andWhere($query->expr()->lt('created_at',
|
||||
$query->createNamedParameter($where['before']->format(DATE_ATOM))));
|
||||
$query->createNamedParameter($where['before']->format(\DATE_ATOM))));
|
||||
}
|
||||
if (isset($where['after'])) {
|
||||
$query->andWhere($query->expr()->gt('created_at',
|
||||
$query->createNamedParameter($where['after']->format(DATE_ATOM))));
|
||||
$query->createNamedParameter($where['after']->format(\DATE_ATOM))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ class DemoListProvider extends BaseProvider {
|
|||
* @return Demo[]
|
||||
*/
|
||||
public function listDemos(int $page, array $where = [], string $order = 'DESC'): array {
|
||||
if (isset($where['players']) and \is_array($where['players']) and \count($where['players']) > 0) {
|
||||
if (isset($where['players']) && \is_array($where['players']) && \count($where['players']) > 0) {
|
||||
return $this->listProfile($page, $where);
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +155,25 @@ class DemoListProvider extends BaseProvider {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param array[] $rows
|
||||
* @param array{
|
||||
* 'id': string,
|
||||
* 'url': string,
|
||||
* 'name': string,
|
||||
* 'server': string,
|
||||
* 'duration': string,
|
||||
* 'nick': string,
|
||||
* 'map': string,
|
||||
* 'created_at': string,
|
||||
* 'red': string,
|
||||
* 'blu': string,
|
||||
* 'scoreRed': string,
|
||||
* 'scoreBlue': string,
|
||||
* 'playerCount': string,
|
||||
* 'uploader': string,
|
||||
* 'hash': string,
|
||||
* 'backend': string,
|
||||
* 'path': string,
|
||||
* }[] $rows
|
||||
*
|
||||
* @return Demo[]
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use Doctrine\DBAL\Connection;
|
|||
use PDO;
|
||||
|
||||
class DemoProvider extends BaseProvider {
|
||||
const VERSION = 4;
|
||||
public const VERSION = 4;
|
||||
|
||||
private UserProvider $userProvider;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Demostf\API\Providers;
|
||||
|
||||
use PDO;
|
||||
|
||||
class InfoProvider extends BaseProvider {
|
||||
/**
|
||||
* @return string[]
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class UserProvider extends BaseProvider {
|
|||
}
|
||||
|
||||
public function getById(int $userId): ?User {
|
||||
if ($userId > pow(2, 31)) {
|
||||
if ($userId > 2 ** 31) {
|
||||
return null;
|
||||
}
|
||||
// first search in the view which contains the most used name for the users
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue