Code Duplication    Length = 19-20 lines in 3 locations

src/Storage/FluentAuthCode.php 1 location

@@ 57-75 (lines=19) @@
54
     *
55
     * @return array Array of \League\OAuth2\Server\Entity\ScopeEntity
56
     */
57
    public function getScopes(AuthCodeEntity $token)
58
    {
59
        $result = $this->getConnection()->table('oauth_auth_code_scopes')
60
            ->select('oauth_scopes.*')
61
            ->join('oauth_scopes', 'oauth_auth_code_scopes.scope_id', '=', 'oauth_scopes.id')
62
            ->where('oauth_auth_code_scopes.auth_code_id', $token->getId())
63
            ->get();
64
65
        $scopes = [];
66
67
        foreach ($result as $scope) {
68
            $scopes[] = (new ScopeEntity($this->getServer()))->hydrate([
69
               'id' => $scope->id,
70
                'description' => $scope->description,
71
            ]);
72
        }
73
74
        return $scopes;
75
    }
76
77
    /**
78
     * Associate a scope with an access token.

src/Storage/FluentAccessToken.php 1 location

@@ 75-94 (lines=20) @@
72
     *
73
     * @return array Array of \League\OAuth2\Server\Entity\ScopeEntity
74
     */
75
    public function getScopes(AccessTokenEntity $token)
76
    {
77
        $result = $this->getConnection()->table('oauth_access_token_scopes')
78
                ->select('oauth_scopes.*')
79
                ->join('oauth_scopes', 'oauth_access_token_scopes.scope_id', '=', 'oauth_scopes.id')
80
                ->where('oauth_access_token_scopes.access_token_id', $token->getId())
81
                ->where('deleted_at', NULL)
82
                ->get();
83
84
        $scopes = [];
85
86
        foreach ($result as $scope) {
87
            $scopes[] = (new ScopeEntity($this->getServer()))->hydrate([
88
               'id' => $scope->id,
89
                'description' => $scope->description,
90
            ]);
91
        }
92
93
        return $scopes;
94
    }
95
96
    /**
97
     * Creates a new access token.

src/Storage/FluentSession.php 1 location

@@ 83-102 (lines=20) @@
80
     *
81
     * @return array Array of \League\OAuth2\Server\Entity\ScopeEntity
82
     */
83
    public function getScopes(SessionEntity $session)
84
    {
85
        // TODO: Check this before pushing
86
        $result = $this->getConnection()->table('oauth_session_scopes')
87
                  ->select('oauth_scopes.*')
88
                  ->join('oauth_scopes', 'oauth_session_scopes.scope_id', '=', 'oauth_scopes.id')
89
                  ->where('oauth_session_scopes.session_id', $session->getId())
90
                  ->get();
91
92
        $scopes = [];
93
94
        foreach ($result as $scope) {
95
            $scopes[] = (new ScopeEntity($this->getServer()))->hydrate([
96
                'id' => $scope->id,
97
                'description' => $scope->description,
98
            ]);
99
        }
100
101
        return $scopes;
102
    }
103
104
    /**
105
     * Create a new session.