Completed
Push — master ( e79a1a...3e0fb7 )
by Miguel
08:55
created

src/ConfigTrait.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 SocialiteProviders\Manager\Contracts\ConfigInterface;
6
7
trait ConfigTrait
8
{
9
    /**
10
     * @var \SocialiteProviders\Manager\Contracts\OAuth1\ProviderInterface|\SocialiteProviders\Manager\Contracts\OAuth2\ProviderInterface
11
     */
12
    protected $config;
13
14
    /**
15
     * @param \SocialiteProviders\Manager\Contracts\OAuth1\ProviderInterface|\SocialiteProviders\Manager\Contracts\OAuth2\ProviderInterface $config
16
     */
17
    public function setConfig(ConfigInterface $config)
18
    {
19
        $config = $config->get();
20
21
        $this->config = $config;
0 ignored issues
show
Documentation Bug introduced by
It seems like $config of type array is incompatible with the declared type object<SocialiteProvider...uth2\ProviderInterface> of property $config.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
22
        $this->clientId = $config['client_id'];
23
        $this->clientSecret = $config['client_secret'];
24
        $this->redirectUrl = $config['redirect'];
25
26
        return $this;
27
    }
28
29
    /**
30
     * @return array
31
     */
32
    public static function additionalConfigKeys()
33
    {
34
        return [];
35
    }
36
37
    /**
38
     * @param string $key
39
     * @param mixed  $default
40
     *
41
     * @return mixed|array
42
     */
43
    protected function getConfig($key = null, $default = null)
44
    {
45
        // check manually if a key is given and if it exists in the config
46
        // this has to be done to check for spoofed additional config keys so that null isn't returned
47
        if (!empty($key) && empty($this->config[$key])) {
48
            return $default;
49
        }
50
51
        return $key ? array_get($this->config, $key, $default) : $this->config;
52
    }
53
}
54