| Conditions | 3 |
| Paths | 3 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 53 | public function block(int $userId): bool |
||
| 54 | { |
||
| 55 | $user = $this->Table->Users->get($userId); |
||
| 56 | if (empty($user)) { |
||
| 57 | throw new \InvalidArgumentException; |
||
| 58 | } |
||
| 59 | |||
| 60 | $conditions = [ |
||
| 61 | 'blocked_by_user_id' => $this->adminId, |
||
| 62 | 'ended IS' => null, |
||
| 63 | 'reason' => $this->getReason(), |
||
| 64 | 'user_id' => $userId |
||
| 65 | ]; |
||
| 66 | |||
| 67 | if ($this->duration) { |
||
| 68 | $conditions['ends'] = bDate(time() + $this->duration); |
||
| 69 | } |
||
| 70 | |||
| 71 | $entity = $this->Table->newEntity($conditions); |
||
| 72 | |||
| 73 | return (bool)$this->Table->save($entity); |
||
| 74 | } |
||
| 75 | } |
||
| 76 |