Showing 16 of 26 total issues
Function validateTypes
has a Cognitive Complexity of 23 (exceeds 9 allowed). Consider refactoring. Open
protected function validateTypes(string $number): bool
{
foreach ($this->types as $type) {
// types that we can't validate are valid
if (!isset(static::$cardTypes[$type])) {
- 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 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validate($value, array $context = []): bool
{
$flags = 0;
$ipName = 'ip address';
Method validate
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validate($value, array $context = []): bool
{
if (!is_string($value) || !$url = parse_url($value)) {
// not a string or not a url
$this->error = new Error(
Function validate
has a Cognitive Complexity of 21 (exceeds 9 allowed). Consider refactoring. Open
public function validate($value, array $context = []): bool
{
if (!is_string($value) || !$url = parse_url($value)) {
// not a string or not a url
$this->error = new Error(
- 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 validate
has a Cognitive Complexity of 19 (exceeds 9 allowed). Consider refactoring. Open
public function validate($value, array $context = []): bool
{
$flags = 0;
$ipName = 'ip address';
- 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 getData
has a Cognitive Complexity of 18 (exceeds 9 allowed). Consider refactoring. Open
public function getData(string $key = null, $validate = true)
{
if ($key !== null) {
if (!isset($this->fields[$key])) {
return null;
- 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 assert
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function assert($field, $value, array $context = [])
{
if (!$field instanceof Field) {
$definitions = [];
if (is_array($field)) {
Method validate
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validate($value, array $context = []): bool
{
if (!is_int($value) && !is_double($value)) {
$this->error = new Error('NO_NUMBER', $value, 'value should be a number');
return false;
Method getData
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getData(string $key = null, $validate = true)
{
if ($key !== null) {
if (!isset($this->fields[$key])) {
return null;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Function assert
has a Cognitive Complexity of 10 (exceeds 9 allowed). Consider refactoring. Open
public static function assert($field, $value, array $context = [])
{
if (!$field instanceof Field) {
$definitions = [];
if (is_array($field)) {
- 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 validate
has a Cognitive Complexity of 10 (exceeds 9 allowed). Consider refactoring. Open
public function validate($value, array $context = [])
{
$filtered = $this->filter($value, $context);
if ($this->filterFailed) {
- 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 addFilterOrValidator
has a Cognitive Complexity of 10 (exceeds 9 allowed). Consider refactoring. Open
public function addFilterOrValidator($definition)
{
if ($definition instanceof FilterInterface) {
$this->addFilter($definition);
} elseif ($definition instanceof ValidatorInterface) {
- 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"