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

valkyrjaio / valkyrja / 16106580260

07 Jul 2025 03:04AM UTC coverage: 42.196% (+2.2%) from 40.004%
16106580260

push

github

MelechMizrachi
Orm: Restructuring and simplifying component.

13 of 452 new or added lines in 38 files covered. (2.88%)

9 existing lines in 3 files now uncovered.

3969 of 9406 relevant lines covered (42.2%)

10.65 hits per line

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

0.0
/src/Valkyrja/Orm/QueryBuilder/SqlUpdateQueryBuilder.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <melechmizrachi@gmail.com>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13

14
namespace Valkyrja\Orm\QueryBuilder;
15

16
use Valkyrja\Orm\Constant\Statement;
17
use Valkyrja\Orm\Data\Value;
18
use Valkyrja\Orm\QueryBuilder\Contract\UpdateQueryBuilder;
19

20
/**
21
 * Class SqlUpdateQueryBuilder.
22
 *
23
 * @author Melech Mizrachi
24
 */
25
class SqlUpdateQueryBuilder extends SqlQueryBuilder implements UpdateQueryBuilder
26
{
27
    /** @var Value[] */
28
    protected array $values = [];
29

30
    /**
31
     * @inheritDoc
32
     */
33
    public function withSet(Value ...$values): static
34
    {
NEW
35
        $new = clone $this;
×
36

NEW
37
        $new->values = $values;
×
38

NEW
39
        return $new;
×
40
    }
41

42
    /**
43
     * @inheritDoc
44
     */
45
    public function withAddedSet(Value ...$values): static
46
    {
NEW
47
        $new = clone $this;
×
48

NEW
49
        $new->values = array_merge($new->values, $values);
×
50

NEW
51
        return $new;
×
52
    }
53

54
    /**
55
     * @inheritDoc
56
     */
57
    public function __toString(): string
58
    {
59
        return Statement::UPDATE
×
NEW
60
            . " $this->from"
×
NEW
61
            . $this->getAliasQuery()
×
NEW
62
            . $this->getSetQuery()
×
NEW
63
            . $this->getWhereQuery()
×
NEW
64
            . $this->getJoinQuery();
×
65
    }
66

67
    /**
68
     * Get the SET part of an INSERT query.
69
     *
70
     * @return string
71
     */
72
    protected function getSetQuery(): string
73
    {
NEW
74
        $values = [];
×
75

NEW
76
        foreach ($this->values as $value) {
×
NEW
77
            $values[] = "$value->name = " . ((string) $value);
×
78
        }
79

NEW
80
        return Statement::SET . ' ' . implode(', ', $values);
×
81
    }
82
}
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