Explorar el Código

Update User\Manager

Visman hace 5 años
padre
commit
490223d169
Se han modificado 1 ficheros con 9 adiciones y 1 borrados
  1. 9 1
      app/Models/User/Manager.php

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

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