UpdateAvatarService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A run() 0 8 1
1
<?php
2
/*
3
 * This file is part of the Laravel Platfourm package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\Platfourm\Auth\Services;
12
13
use GuzzleHttp\Client;
14
use Illuminate\Contracts\Cache\Repository as Cache;
15
use Longman\Platfourm\Contracts\Auth\AuthUserService;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Longman\Platfourm\Auth\Services\AuthUserService.

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...
16
use Longman\Platfourm\Service\EntityService;
17
use Longman\Platfourm\User\Repositories\Eloquent\UserRepository;
18
19
class UpdateAvatarService extends EntityService
20
{
21
    protected $repository;
22
    protected $authUserService;
23
    protected $httpClient;
24
    protected $cache;
25
26
    public function __construct(
27
        AuthUserService $authUserService,
28
        UserRepository $repository,
29
        Client $httpClient,
30
        Cache $cache
31
    ) {
32
        $this->authUserService = $authUserService;
33
        $this->repository      = $repository;
34
        $this->httpClient      = $httpClient;
35
        $this->cache           = $cache;
36
    }
37
38
    public function run()
39
    {
40
        $this->checkRepository();
41
42
        $data = $this->repository->updateAvatar($this->httpClient, $this->cache, $this->authUserService);
43
44
        return $data;
45
    }
46
}
47