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
|
|
|
|
{
|
|
|
|
/** @var User */
|
|
|
|
public static $user = null;
|
|
|
|
|
|
|
|
/** @var int */
|
|
|
|
public static $id = null;
|
|
|
|
|
2018-10-11 01:26:34 +02:00
|
|
|
/** @var int */
|
|
|
|
public static $apiKey = null;
|
|
|
|
|
2018-10-08 19:30:37 +02:00
|
|
|
/**
|
|
|
|
* @param array $columns
|
|
|
|
*/
|
2022-12-14 19:15:20 +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
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public static function whereApiKey(string $apiKey): array|Collection|QueryBuilder
|
2018-10-11 01:26:34 +02:00
|
|
|
{
|
|
|
|
if ($apiKey != static::$apiKey) {
|
|
|
|
throw new InvalidArgumentException('Wrong api key searched');
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Collection([self::$user]);
|
|
|
|
}
|
2018-10-08 19:30:37 +02:00
|
|
|
}
|