protected function assignPrimaryTitle(array & $mappers)
    {
        $fieldsWithHeader = array_filter($mappers, function ($mapper) {
            return $mapper->field->isHeader;
        });

        if (count($fieldsWithHeader) == 0) {
            $found = false;

            foreach ($mappers as $mapper) {
                if ($found) {
                    $mapper->field->isHeader = false;
                    continue;
                }
  
                if ($this->isPrimaryHeader($mapper->field) && (! array_key_exists('is-header', $mapper->meta) || $mapper->meta['is-header'])) {
                    $found = true;
                    $mapper->field->isHeader = true;
                }
            }
        }

        return $this;
    }
protected function assignPrimaryTitle(array & $mappers)
    {
        $fieldsWithHeader = array_filter($mappers, function ($mapper) {
            return $mapper->field->isHeader;
        });

        if (count($fieldsWithHeader) == 0) {
            $found = false;

            foreach ($mappers as $mapper) {
                if ($found) {
                    $mapper->field->isHeader = false;
                    continue;
                }
  
                if ($this->isPrimaryHeader($mapper->field) && (! array_key_exists('is-header', $mapper->meta) || $mapper->meta['is-header'])) {
                    $found = true;
                    $mapper->field->isHeader = true;
                }
            }
        }

        return $this;
    }
protected function assignPrimaryTitle ( array & $ mappers ) { $ fieldsWithHeader = array_filter ( $ mappers , function ( $ mapper ) { return $ mapper -> field -> isHeader ; } ) ; if ( count ( $ fieldsWithHeader ) == 0 ) { $ found = false ; foreach ( $ mappers as $ mapper ) { if ( $ found ) { $ mapper -> field -> isHeader = false ; continue ; } if ( $ this -> isPrimaryHeader ( $ mapper -> field ) && ( ! array_key_exists ( 'is-header' , $ mapper -> meta ) || $ mapper -> meta [ 'is-header' ] ) ) { $ found = true ; $ mapper -> field -> isHeader = true ; } } } return $ this ; }
given a mappers collection, it'll update the the field by making one as primary title

@param CrestApps\CodeGenerator\Models\Field $field
@return bool
given a mappers collection it ll update the the field by making one as primary title