CheckMailService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 24
loc 24
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A run() 10 10 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 App\Contracts\Services\Auth\AuthUserService as AuthUserServiceContract;
14
use App\Exceptions\RepositoryNotFoundException;
15
use App\Repositories\Identity\UserRepository;
16
use App\Repositories\Repository;
17
use App\Services\EntityService;
18
use App\Services\ServiceDispatcher;
19
20 View Code Duplication
class CheckMailService extends EntityService
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    protected $repository;
23
    protected $authUserService;
24
25
    public function __construct(
26
        AuthUserServiceContract $authUserService,
27
        UserRepository $repository
28
    ) {
29
        $this->authUserService = $authUserService;
30
        $this->repository      = $repository;
31
    }
32
33
    public function run($mail)
34
    {
35
        if (!($this->repository instanceof Repository)) {
0 ignored issues
show
Bug introduced by
The class App\Repositories\Repository does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
36
            throw new RepositoryNotFoundException;
37
        }
38
39
        $item = $this->repository->findBy('email', $mail);
40
41
        return $item;
42
    }
43
}
44