protected function getUser($userId = null)
    {
        if ($userId === null) {
            /** @var Token $sessionAuth */
            if ($this->session()->isStarted() && $sessionAuth = $this->session()->get('authentication')) {
                return $sessionAuth->getUser();
            }

            return false;
        }
        /** @var Repository\UsersRepository $repo */
        $repo = $this->storage()->getRepository(Entity\Users::class);

        return $repo->getUser($userId);
    }
protected function getUser($userId = null)
    {
        if ($userId === null) {
            /** @var Token $sessionAuth */
            if ($this->session()->isStarted() && $sessionAuth = $this->session()->get('authentication')) {
                return $sessionAuth->getUser();
            }

            return false;
        }
        /** @var Repository\UsersRepository $repo */
        $repo = $this->storage()->getRepository(Entity\Users::class);

        return $repo->getUser($userId);
    }
protected function getUser ( $ userId = null ) { if ( $ userId === null ) { /** @var Token $sessionAuth */ if ( $ this -> session ( ) -> isStarted ( ) && $ sessionAuth = $ this -> session ( ) -> get ( 'authentication' ) ) { return $ sessionAuth -> getUser ( ) ; } return false ; } /** @var Repository\UsersRepository $repo */ $ repo = $ this -> storage ( ) -> getRepository ( Entity \ Users :: class ) ; return $ repo -> getUser ( $ userId ) ; }
Return current user or user by ID.

@param int|string|null $userId

@return Entity\Users|false
Return current user or user by ID .