Function attachByMethod
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
protected function attachByMethod(string $method)
{
if ($this->$method) {
foreach ($this->$method as $attachModel) {
$class = new \ReflectionClass($this);
Function filterByFields
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
protected function filterByFields(array $results, array $fields) : array
{
if (!$fields) {
return $results;
}
Function attachHABTM
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
protected function attachHABTM()
{
if ($this->hasAndBelongsToMany) {
foreach ($this->hasAndBelongsToMany as $habtmModel) {
$class = new \ReflectionClass($this);
Function validateRequiredFields
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
protected function validateRequiredFields(array $data)
{
if ($this->requiredFields) {
foreach ($this->requiredFields as $requiredField) {
if (!array_key_exists($requiredField, $data)) {
Function validateUniqueFields
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
protected function validateUniqueFields(array $data)
{
if ($this->uniqueFields) {
foreach ($this->uniqueFields as $uniqueField) {
$check = $this->getBySearch([$uniqueField => $data[$uniqueField]]);