• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nextras / orm / 11646071501

02 Nov 2024 09:51PM UTC coverage: 92.046% (-0.02%) from 92.062%
11646071501

push

github

web-flow
Merge pull request #698 from nextras/fix-lifting

Fix having lifting required by row aggregator

4 of 5 new or added lines in 5 files covered. (80.0%)

4062 of 4413 relevant lines covered (92.05%)

3.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/src/Collection/Aggregations/NumericAggregator.php
1
<?php declare(strict_types = 1);
2

3
namespace Nextras\Orm\Collection\Aggregations;
4

5

6
use Nextras\Orm\Collection\Expression\ExpressionContext;
7
use Nextras\Orm\Collection\Functions\Result\DbalExpressionResult;
8

9

10
/**
11
 * @internal
12
 * @implements Aggregator<number>
13
 */
14
class NumericAggregator implements Aggregator
15
{
16
        /**
17
         * @param callable(array<number>): (number|null) $arrayAggregation
18
         * @param literal-string $dbalAggregationFunction
19
         */
20
        public function __construct(
4✔
21
                private readonly mixed $arrayAggregation,
22
                private readonly string $dbalAggregationFunction,
23
        )
24
        {
25
        }
4✔
26

27

28
        public function getAggregateKey(): string
29
        {
30
                return '_' . $this->dbalAggregationFunction;
4✔
31
        }
32

33

34
        public function aggregateValues(array $values): mixed
35
        {
36
                $cb = $this->arrayAggregation;
4✔
37
                return $cb($values);
4✔
38
        }
39

40

41
        public function aggregateExpression(
42
                DbalExpressionResult $expression,
43
                ExpressionContext $context,
44
        ): DbalExpressionResult
45
        {
46
                return new DbalExpressionResult(
4✔
47
                        expression: null,
4✔
48
                        args: [],
4✔
49
                        joins: $expression->joins,
4✔
50
                        groupBy: $expression->groupBy,
4✔
51
                        havingExpression: "{$this->dbalAggregationFunction}($expression->expression)",
4✔
52
                        havingArgs: $expression->args,
4✔
53
                );
54
        }
55

56

57
        public function isHavingClauseRequired(): bool
58
        {
NEW
59
                return true;
×
60
        }
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc