2018-10-08 19:30:37 +02:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-10-08 19:30:37 +02:00
|
|
|
namespace Engelsystem\Test\Unit\Helpers\Stub;
|
|
|
|
|
|
|
|
use Engelsystem\Models\User\User;
|
2018-10-11 01:26:34 +02:00
|
|
|
use Illuminate\Database\Eloquent\Collection;
|
2019-11-06 13:16:00 +01:00
|
|
|
use Illuminate\Database\Query\Builder as QueryBuilder;
|
2018-10-08 19:30:37 +02:00
|
|
|
use InvalidArgumentException;
|
|
|
|
|
|
|
|
class UserModelImplementation extends User
|
|
|
|
{
|
2022-12-15 19:50:56 +01:00
|
|
|
public static ?User $user = null;
|
2018-10-08 19:30:37 +02:00
|
|
|
|
2022-12-15 19:50:56 +01:00
|
|
|
public static ?int $id = null;
|
2018-10-08 19:30:37 +02:00
|
|
|
|
2022-12-15 19:50:56 +01:00
|
|
|
public static ?string $apiKey = null;
|
2018-10-11 01:26:34 +02:00
|
|
|
|
2024-03-25 00:03:39 +01:00
|
|
|
/**
|
|
|
|
* @param mixed $id
|
|
|
|
* @param array $columns
|
|
|
|
*/
|
|
|
|
public function find($id, $columns = ['*']): ?User // phpcs:ignore
|
2018-10-08 19:30:37 +02:00
|
|
|
{
|
|
|
|
if ($id != static::$id) {
|
|
|
|
throw new InvalidArgumentException('Wrong user ID searched');
|
|
|
|
}
|
|
|
|
|
|
|
|
return self::$user;
|
|
|
|
}
|
2018-10-11 01:26:34 +02:00
|
|
|
|
|
|
|
/**
|
2019-11-06 13:16:00 +01:00
|
|
|
* @return User[]|Collection|QueryBuilder
|
2018-10-11 01:26:34 +02:00
|
|
|
*/
|
2024-03-25 00:03:39 +01:00
|
|
|
public static function whereApiKey(string $value): array|Collection|QueryBuilder
|
2018-10-11 01:26:34 +02:00
|
|
|
{
|
2024-03-25 00:03:39 +01:00
|
|
|
if ($value != static::$apiKey) {
|
2018-10-11 01:26:34 +02:00
|
|
|
throw new InvalidArgumentException('Wrong api key searched');
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Collection([self::$user]);
|
|
|
|
}
|
2018-10-08 19:30:37 +02:00
|
|
|
}
|