Completed
Push — master ( 17ee4a...c5eac5 )
by Atymic
10:15
created

src/Config.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace SocialiteProviders\Manager;
4
5
use Illuminate\Support\Facades\URL;
6
use Illuminate\Support\Str;
7
8
class Config implements Contracts\ConfigInterface
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $config;
14
15
    /**
16
     * Config constructor.
17 13
     *
18
     * @param string $key
19 13
     * @param string $secret
20 13
     * @param string|callable $callbackUri
21 13
     * @param array  $additionalProviderConfig
22 13
     */
23 13
    public function __construct($key, $secret, $callbackUri, array $additionalProviderConfig = [])
24 13
    {
25
        $this->config = array_merge([
26
            'client_id'     => $key,
27
            'client_secret' => $secret,
28
            'redirect'      => $this->formatRedirectUri($callbackUri),
0 ignored issues
show
$callbackUri is of type callable, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
29 9
        ], $additionalProviderConfig);
30
    }
31 9
32
    /**
33
     * Format the callback URI, resolving a relative URI if needed.
34
     *
35
     * @param  string  $callbackUri
36
     * @return string
37
     */
38
    protected function formatRedirectUri($callbackUri)
39
    {
40
        $redirect = value($callbackUri);
41
42
        return Str::startsWith($redirect, '/')
43
                    ? URL::to($redirect)
44
                    : $redirect;
45
    }
46
47
    /**
48
     * @return array
49
     */
50
    public function get()
51
    {
52
        return $this->config;
53
    }
54
}
55