mcred/phpred

View on GitHub

Showing 5 of 5 total issues

Function attachByMethod has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

protected function attachByMethod(string $method)
{
if ($this->$method) {
foreach ($this->$method as $attachModel) {
$class = new \ReflectionClass($this);
Severity: Minor
Found in src/Models/Model.php - About 55 mins to fix

Function filterByFields has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

protected function filterByFields(array $results, array $fields) : array
{
if (!$fields) {
return $results;
}
Severity: Minor
Found in src/Models/Model.php - About 45 mins to fix

Function attachHABTM has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

protected function attachHABTM()
{
if ($this->hasAndBelongsToMany) {
foreach ($this->hasAndBelongsToMany as $habtmModel) {
$class = new \ReflectionClass($this);
Severity: Minor
Found in src/Models/Model.php - About 25 mins to fix

Function validateRequiredFields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

protected function validateRequiredFields(array $data)
{
if ($this->requiredFields) {
foreach ($this->requiredFields as $requiredField) {
if (!array_key_exists($requiredField, $data)) {
Severity: Minor
Found in src/Models/Model.php - About 25 mins to fix

Function validateUniqueFields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

protected function validateUniqueFields(array $data)
{
if ($this->uniqueFields) {
foreach ($this->uniqueFields as $uniqueField) {
$check = $this->getBySearch([$uniqueField => $data[$uniqueField]]);
Severity: Minor
Found in src/Models/Model.php - About 25 mins to fix
Severity
Category
Status
Source
Language