Parcourir la source

Update User\Manager

Visman il y a 5 ans
Parent
commit
490223d169
1 fichiers modifiés avec 9 ajouts et 1 suppressions
  1. 9 1
      app/Models/User/Manager.php

+ 9 - 1
app/Models/User/Manager.php

@@ -22,9 +22,15 @@ class Manager extends ManagerModel
 
     /**
      * Получает пользователя по id
+     *
+     * @throws InvalidArgumentException
      */
     public function load(int $id): ?User
     {
+        if ($id < 1) {
+            throw new InvalidArgumentException('Expected id > 0');
+        }
+
         if ($this->isset($id)) {
             return $this->get($id);
         } else {
@@ -36,6 +42,8 @@ class Manager extends ManagerModel
 
     /**
      * Получает массив пользователей по ids
+     *
+     * @throws InvalidArgumentException
      */
     public function loadByIds(array $ids): array
     {
@@ -44,7 +52,7 @@ class Manager extends ManagerModel
 
         foreach ($ids as $id) {
             if (! \is_int($id) || $id < 1) {
-                throw new InvalidArgumentException('Expected a positive integer');
+                throw new InvalidArgumentException('Expected id > 0');
             }
             if ($this->isset($id)) {
                 $result[$id] = $this->get($id);