Issues (174)

src/Models/Clients/Client.php (6 issues)

1
<?php
2
3
namespace ByTIC\Hello\Models\Clients;
4
5
use ByTIC\Hello\Utility\RandomHelper;
6
use League\OAuth2\Server\Entities\ClientEntityInterface;
7
use League\OAuth2\Server\Entities\Traits\ClientTrait;
8
use League\OAuth2\Server\Entities\Traits\EntityTrait;
9
10
/**
11
 * Class Token
12
 * @package ByTIC\Hello\Models\Clients
13
 */
14
class Client extends \Nip\Records\Record implements ClientEntityInterface
15
{
16 1
    use ClientTrait;
17 1
    use EntityTrait;
18 1
    use Traits\ClientHasGrantsTrait;
0 ignored issues
show
The trait ByTIC\Hello\Models\Clien...ts\ClientHasGrantsTrait requires the property $grant_types which is not provided by ByTIC\Hello\Models\Clients\Client.
Loading history...
19 1
    use Traits\ClientHasSecretTrait;
20 1
    use Traits\ClientHasRedirectTrait;
21
22 20
    public function __construct()
23
    {
24 20
        $this->setIdentifier(RandomHelper::generateIdentifier());
25 20
        $this->setSecret(RandomHelper::generateToken());
26 20
    }
27
28
    /**
29
     * @inheritDoc
30
     */
31 10
    public function writeData($data = false)
32
    {
33 10
        parent::writeData($data);
34
35 10
        if (isset($data['grant_types']) && !empty($data['grant_types'])) {
36 2
            $this->initGrantsFromDb($data['grant_types']);
37
        }
38
39 10
        if (isset($data['identifier']) && !empty($data['identifier'])) {
40 1
            $this->initIdentifierFromDb($data['identifier']);
41
        }
42 10
    }
43
44
    /**
45
     * @inheritDoc
46
     */
47 20
    public function setIdentifier($identifier)
48
    {
49 20
        $this->setDataValue('identifier', $identifier);
0 ignored issues
show
Deprecated Code introduced by
The function ByTIC\DataObjects\AbstractDto::setDataValue() has been deprecated: use ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

49
        /** @scrutinizer ignore-deprecated */ $this->setDataValue('identifier', $identifier);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
50 20
        $this->identifier = $identifier;
51 20
    }
52
53
    /**
54
     * @param null $data
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $data is correct as it would always require null to be passed?
Loading history...
55
     */
56 1
    public function initIdentifierFromDb($data = null)
57
    {
58 1
        $data = $data === null ? $this->_data['identifier'] : $data;
0 ignored issues
show
Bug Best Practice introduced by
The property _data does not exist on ByTIC\Hello\Models\Clients\Client. Since you implemented __get, consider adding a @property annotation.
Loading history...
The condition $data === null is always true.
Loading history...
59 1
        if (!empty($data)) {
60 1
            $this->setIdentifier($data);
61
        }
62 1
    }
63
64
    /**
65
     * @param mixed $name
66
     */
67 4
    public function setName($name)
68
    {
69 4
        $this->name = $name;
70 4
        parent::setDataValue('name', $name);
0 ignored issues
show
Deprecated Code introduced by
The function ByTIC\DataObjects\Legacy...nsTrait::setDataValue() has been deprecated: use ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

70
        /** @scrutinizer ignore-deprecated */ parent::setDataValue('name', $name);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
71 4
    }
72
}
73