Completed
Push — master ( 6e52f0...d9a404 )
by Alexandre
02:29
created

UserAgentBasedApplication::useImplicit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 0
cts 3
cp 0
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Alexandre
5
 * Date: 30/12/2017
6
 * Time: 17:02
7
 */
8
9
namespace OAuth2OLD\Role\Client;
10
11
use OAuth2OLD\Role\Client\Type\PublicClient;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, OAuth2OLD\Role\Client\PublicClient. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
12
13
14
/**
15
 * Class UserAgentBasedApplication
16
 * @package OAuth2\Roles\Clients
17
 *
18
 * @see https://tools.ietf.org/html/rfc6749#section-2.1
19
 *
20
 * Client Types
21
 *
22
 *     A user-agent-based application is a public client in which the
23
 * client code is downloaded from a web server and executes within a
24
 * user-agent (e.g., web browser) on the device used by the resource
25
 * owner.  Protocol data and credentials are easily accessible (and
26
 * often visible) to the resource owner.  Since such applications
27
 * reside within the user-agent, they can make seamless use of the
28
 * user-agent capabilities when requesting authorization.
29
 */
30
class UserAgentBasedApplication extends PublicClient
31
{
32
33
    /**
34
     * @var bool
35
     */
36
    private $useImplicit;
37
38
    public function __construct($identifier, array $redirectUris = null, bool $useImplicit = false)
39
    {
40
        parent::__construct($identifier, $redirectUris);
0 ignored issues
show
Bug introduced by
The call to OAuth2OLD\Role\Client\Re...edClient::__construct() has too few arguments starting with supportedScopes. ( Ignorable by Annotation )

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

40
        parent::/** @scrutinizer ignore-call */ 
41
                __construct($identifier, $redirectUris);

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
41
        $this->useImplicit = $useImplicit;
42
    }
43
44
    function useImplicit(): bool
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
45
    {
46
        return $this->useImplicit;
47
    }
48
}