firefly-iii/app/Repositories/User/UserRepositoryInterface.php

174 lines
3.9 KiB
PHP
Raw Normal View History

2016-03-12 07:18:28 -06:00
<?php
/**
* UserRepositoryInterface.php
2017-10-21 01:40:00 -05:00
* Copyright (c) 2017 thegrumpydictator@gmail.com
2016-03-12 07:18:28 -06:00
*
2017-10-21 01:40:00 -05:00
* This file is part of Firefly III.
*
2017-10-21 01:40:00 -05:00
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2017-12-17 07:44:05 -06:00
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
2016-03-12 07:18:28 -06:00
*/
2017-03-24 09:01:53 -05:00
declare(strict_types=1);
2016-03-12 07:18:28 -06:00
namespace FireflyIII\Repositories\User;
2018-01-21 11:06:57 -06:00
use FireflyIII\Models\Role;
2016-03-12 07:18:28 -06:00
use FireflyIII\User;
2016-04-03 00:07:17 -05:00
use Illuminate\Support\Collection;
2016-03-12 07:18:28 -06:00
/**
2017-11-15 05:25:49 -06:00
* Interface UserRepositoryInterface.
2016-03-12 07:18:28 -06:00
*/
interface UserRepositoryInterface
{
2018-01-21 11:06:57 -06:00
/**
* @param string $name
* @param string $displayName
* @param string $description
*
* @return Role
*/
public function createRole(string $name, string $displayName, string $description): Role;
2016-04-03 00:07:17 -05:00
/**
2016-04-26 01:09:10 -05:00
* Returns a collection of all users.
*
2016-04-03 00:07:17 -05:00
* @return Collection
*/
public function all(): Collection;
2018-01-21 11:06:57 -06:00
/**
* @param string $role
*
* @return Role|null
*/
public function getRole(string $role): ?Role;
2016-03-12 07:18:28 -06:00
/**
2016-04-26 01:09:10 -05:00
* Gives a user a role.
*
2016-03-12 07:18:28 -06:00
* @param User $user
* @param string $role
*
* @return bool
*/
public function attachRole(User $user, string $role): bool;
/**
2017-09-26 02:15:21 -05:00
* This updates the users email address and records some things so it can be confirmed or undone later.
* The user is blocked until the change is confirmed.
*
* @param User $user
* @param string $newEmail
*
2017-09-26 02:15:21 -05:00
* @see updateEmail
*
* @return bool
*/
public function changeEmail(User $user, string $newEmail): bool;
2016-12-18 10:54:11 -06:00
/**
* @param User $user
* @param string $password
*
* @return mixed
*/
public function changePassword(User $user, string $password);
2017-03-24 09:01:53 -05:00
/**
* @param User $user
2017-03-24 09:01:53 -05:00
* @param bool $isBlocked
* @param string $code
*
* @return bool
*/
public function changeStatus(User $user, bool $isBlocked, string $code): bool;
2016-03-12 07:18:28 -06:00
/**
2016-04-26 01:09:10 -05:00
* Returns a count of all users.
2016-04-26 14:40:15 -05:00
*
2016-03-12 07:18:28 -06:00
* @return int
*/
public function count(): int;
2016-10-22 02:33:03 -05:00
2016-12-12 08:24:47 -06:00
/**
* @param User $user
*
* @return bool
*/
public function destroy(User $user): bool;
2016-10-22 02:33:03 -05:00
/**
* @param int $userId
*
* @return User
*/
public function find(int $userId): User;
/**
* @param string $email
*
* @return User|null
*/
public function findByEmail(string $email): ?User;
2017-12-29 02:05:35 -06:00
/**
* Returns the first user in the DB. Generally only works when there is just one.
*
* @return null|User
*/
public function first(): ?User;
2016-10-22 02:33:03 -05:00
/**
* Return basic user information.
*
* @param User $user
*
* @return array
*/
public function getUserData(User $user): array;
2017-03-19 11:54:21 -05:00
/**
* @param User $user
* @param string $role
*
* @return bool
*/
public function hasRole(User $user, string $role): bool;
2017-09-26 02:15:21 -05:00
2017-12-29 02:05:35 -06:00
/**
* @param array $data
*
* @return User
*/
public function store(array $data): User;
/**
* @param User $user
*/
public function unblockUser(User $user): void;
2017-09-26 02:15:21 -05:00
/**
* This updates the users email address. Same as changeEmail just without most logging. This makes sure that the undo/confirm routine can't catch this one.
* The user is NOT blocked.
*
* @param User $user
* @param string $newEmail
*
* @see changeEmail
*
* @return bool
*/
public function updateEmail(User $user, string $newEmail): bool;
2016-03-14 14:38:23 -05:00
}