2018-10-08 19:30:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
public static ?User $user = null;
|
|
|
|
|
|
|
|
public static ?int $id = null;
|
|
|
|
|
2018-10-11 01:26:34 +02:00
|
|
|
public static ?string $apiKey = null;
|
|
|
|
|
2019-11-06 13:16:00 +01:00
|
|
|
public function find(mixed $id, array $columns = ['*']): ?User
|
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
|
|
|
*/
|
|
|
|
public static function whereApiKey(string $apiKey): array|Collection|QueryBuilder
|
|
|
|
{
|
|
|
|
if ($apiKey != static::$apiKey) {
|
|
|
|
throw new InvalidArgumentException('Wrong api key searched');
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Collection([self::$user]);
|
|
|
|
}
|
2018-10-08 19:30:37 +02:00
|
|
|
}
|