Code Duplication    Length = 19-20 lines in 3 locations

src/Storage/FluentAccessToken.php 1 location

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

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/FluentSession.php 1 location

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