public function deleteUserBySlug($slug)
    {
        $userToDelete = $this->getUserBySlug($slug);
        if (empty($userToDelete)) {
            throw new \Exception('Trying to delete a user that doesn\'t exist.');
        }
        $users = $this->getUsers();
        foreach ($users as $key => $user) {
            if ($user->slug == $userToDelete->slug) {
                unset($users[$key]);
                $this->repository->users = array_values($users);
            }
        }
        $this->save();
    }
public function deleteUserBySlug($slug)
    {
        $userToDelete = $this->getUserBySlug($slug);
        if (empty($userToDelete)) {
            throw new \Exception('Trying to delete a user that doesn\'t exist.');
        }
        $users = $this->getUsers();
        foreach ($users as $key => $user) {
            if ($user->slug == $userToDelete->slug) {
                unset($users[$key]);
                $this->repository->users = array_values($users);
            }
        }
        $this->save();
    }
public function deleteUserBySlug ( $ slug ) { $ userToDelete = $ this -> getUserBySlug ( $ slug ) ; if ( empty ( $ userToDelete ) ) { throw new \ Exception ( 'Trying to delete a user that doesn\'t exist.' ) ; } $ users = $ this -> getUsers ( ) ; foreach ( $ users as $ key => $ user ) { if ( $ user -> slug == $ userToDelete -> slug ) { unset ( $ users [ $ key ] ) ; $ this -> repository -> users = array_values ( $ users ) ; } } $ this -> save ( ) ; }
Delete user by slug

@param $slug

@throws \Exception
Delete user by slug