Validation
has 34 functions (exceeds 20 allowed). Consider refactoring. Open
class Validation {
/**
* validation errors
*
Function validate
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function validate($data, $skip = false){
$passed = true;
foreach($data as $placeholder => $rules){
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File Validation.php
has 276 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Validation class
*
Function isEmpty
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private function isEmpty($value){
if(is_null($value)) {
return true;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function addError
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function addError($rule, $placeholder, $value, $args = []){
if(isset($this->ruleMessages[$rule])){
$this->errors[] = $this->ruleMessages[$rule];
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method validate
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validate($data, $skip = false){
$passed = true;
foreach($data as $placeholder => $rules){
Method defaultMessages
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function defaultMessages($rule){
$messages = [
"required" => "{placeholder} can't be empty",
"minLen" => "{placeholder} can't be less than {0} character",
"maxLen" => "{placeholder} can't be greater than {0} character",
Function emailUnique
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function emailUnique($email){
$database = Database::openConnection();
// email is unique in the database, So, we can't have more than 2 same emails
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return false;
Function inArray
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function inArray($value, $arr){
if(is_array($value)){
foreach($value as $val){
if(!in_array($val, $arr, true)){
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"