Completed
Push — master ( f2288e...d698ce )
by Daniel
01:37
created

ShopifyAdminUserProvider::loadUserByUsername()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 1
nop 1
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace CodeCloud\Bundle\ShopifyBundle\Security;
4
5
use CodeCloud\Bundle\ShopifyBundle\Model\ShopifyStoreManagerInterface;
6
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Securi...ernameNotFoundException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Symfony\Component\Security\Core\User\UserInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Security\Core\User\UserInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Symfony\Component\Security\Core\User\UserProviderInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Securi...r\UserProviderInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
class ShopifyAdminUserProvider implements UserProviderInterface
11
{
12
    const ROLE_SHOPIFY_ADMIN = 'ROLE_SHOPIFY_ADMIN';
13
14
    /**
15
     * @var ShopifyStoreManagerInterface
16
     */
17
    private $storeManager;
18
19
    /**
20
     * @param ShopifyStoreManagerInterface $storeManager
21
     */
22
    public function __construct(ShopifyStoreManagerInterface $storeManager)
23
    {
24
        $this->storeManager = $storeManager;
25
    }
26
27
    public function loadUserByUsername($username)
28
    {
29
        if (!$this->storeManager->storeExists($username)) {
30
            throw new UsernameNotFoundException();
31
        }
32
33
        return new ShopifyAdminUser($username, [self::ROLE_SHOPIFY_ADMIN]);
34
    }
35
36
    public function refreshUser(UserInterface $user)
37
    {
38
        return $user;
39
    }
40
41
    public function supportsClass($class)
42
    {
43
        return $class instanceof ShopifyAdminUser;
44
    }
45
}
46