EmailAvailable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 14
loc 14
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A test() 4 4 1

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
namespace App\Validation\Rules;
4
5
use Albert221\Validation\Rule\RuleInterface;
6
use Albert221\Validation\Rule\RuleTrait as RuleTrait;
7
use App\Models\User;
8
9 View Code Duplication
class EmailAvailable implements RuleInterface
10
{
11
    use RuleTrait;
12
13
    public function __construct()
14
    {
15
        $this->message = 'Ten adres email jest już zajęty';
16
    }
17
18
    public function test($value)
19
    {
20
        return User::where('email', $value)->count() === 0;
21
    }
22
}
23