aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/OAuth2/Models/Scope.php
blob: 86bf81551db3109ec19e782b996b858db03ecabc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php

namespace Studip\OAuth2\Models;

class Scope
{
    /**
     * @var string
     */
    public $id;

    /**
     * @var string
     */
    public $description;

    /**
     * @param string $id
     * @param string $description
     *
     * @return void
     */
    public function __construct($id, $description)
    {
        $this->id = $id;
        $this->description = $description;
    }

    /**
     * @return static[]
     */
    public static function scopes()
    {
        return [
            'api' => new Scope('api', _('Gewährt vollständigen Lese-/Schreibzugriff auf die API.')),
        ];
    }

    /**
     * @return array
     */
    public function toArray()
    {
        return [
            'id' => $this->id,
            'description' => $this->description,
        ];
    }

    /**
     * @param int $options
     *
     * @return string
     */
    public function toJson($options = 0)
    {
        return json_encode($this->toArray(), $options);
    }
}