Showing 228 of 247 total issues
Function tryLoad
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
#[\Override]
public function tryLoad(Model $model, $id): ?array
{
$model->assertIsModel();
- Read upRead up
- Create a ticketCreate a ticket
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 _renderTable
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function _renderTable($addAlias = true): ?string
{
$res = [];
foreach ($this->args['table'] ?? [] as $alias => $table) {
if ($addAlias === false && $table instanceof self) {
- Read upRead up
- Create a ticketCreate a ticket
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 makeHashFromKey
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function makeHashFromKey($value, ?\HashContext $hashContext = null): ?int
{
if ($hashContext === null) {
$hashContext = hash_init('crc32c');
$return = true;
- Read upRead up
- Create a ticketCreate a ticket
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 addField
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function addField(string $fieldName, array $defaults = []): Field
{
if (!isset($defaults['aggregate']) && !isset($defaults['concat']) && !isset($defaults['expr'])) {
throw (new Exception('Aggregate field requires "aggregate", "concat" or "expr" specified to hasMany()->addField()'))
->addMoreInfo('field', $fieldName)
- Read upRead up
- Create a ticketCreate a ticket
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 setGroupBy
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function setGroupBy(array $fields, array $aggregateExpressions = [])
{
foreach ($fields as $fieldName) {
if ($fieldName instanceof Expression || $this->hasField($fieldName)) {
continue;
- Read upRead up
- Create a ticketCreate a ticket
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 where
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function where($field, $operator = null, $value = null, $kind = 'where', $numArgs = null)
{
// number of passed arguments will be used to determine if arguments were specified or not
if ($numArgs === null) {
$numArgs = 'func_num_args'();
- Create a ticketCreate a ticket
Method _subrenderCondition
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
#[\Override]
protected function _subrenderCondition(array $row): string
{
if (count($row) !== 1) {
[$field, $operator, $value] = $row;
- Create a ticketCreate a ticket
Method wrap
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
#[\Override]
public function wrap(Driver $driver): Driver
{
return new class($driver) extends AbstractDriverMiddleware {
#[\Override]
- Create a ticketCreate a ticket
Method set
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function set(string $field, $value)
{
$this->getModel()->assertOnlyField($field);
$f = $this->getField($field);
- Create a ticketCreate a ticket
Method createForeignKey
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createForeignKey($relation): void
{
[$localField, $foreignField] = is_array($relation)
? $relation
: $this->resolveRelationDirection($relation);
- Create a ticketCreate a ticket
Method initQueryFields
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function initQueryFields(Model $model, Query $query, ?array $fields = null): void
{
// init fields
if ($fields !== null) {
// set of fields is strictly defined, so we will ignore even system fields
- Create a ticketCreate a ticket
Method ref
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
#[\Override]
public function ref(Model $ourModelOrEntity, array $defaults = []): Model
{
$this->assertOurModelOrEntity($ourModelOrEntity);
- Create a ticketCreate a ticket
Method escapeStringLiteral
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
#[\Override]
protected function escapeStringLiteral(string $value): string
{
$dummyPersistence = (new \ReflectionClass(Persistence\Sql::class))->newInstanceWithoutConstructor();
if (\Closure::bind(static fn () => $dummyPersistence->explicitCastIsEncodedBinary($value), null, Persistence\Sql::class)()) {
- Create a ticketCreate a ticket
Method setModel
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setModel(Model $model): Model
{
$this->table($model->table);
foreach ($model->getFields() as $field) {
- Create a ticketCreate a ticket
Method action
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
#[\Override]
public function action(string $mode, array $args = [])
{
switch ($mode) {
case 'select':
- Create a ticketCreate a ticket
Method _renderCase
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _renderCase(): ?string
{
if (!isset($this->args['case_when'])) {
return null;
}
- Create a ticketCreate a ticket
Method getConnection
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
#[\Override]
public function getConnection(): Persistence\Sql\Connection
{
\Closure::bind(function () {
if (($this->_connection ?? null) === null) {
- Create a ticketCreate a ticket
Method validateBeforeExecute
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function validateBeforeExecute(): void
{
if ($this->enabled === false || ($this->enabled instanceof \Closure && ($this->enabled)($this->_getOwner()) === false)) {
throw new Exception('User action is disabled');
}
- Create a ticketCreate a ticket
Method init
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
#[\Override]
protected function init(): void
{
parent::init();
- Create a ticketCreate a ticket
Method setOrder
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setOrder($field, string $direction = 'asc')
{
$this->assertIsModel();
// fields passed as array
- Create a ticketCreate a ticket