• 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/SqlInsertQueryBuilder.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\InsertQueryBuilder as Contract;
19

20
/**
21
 * Class SqlInsertQueryBuilder.
22
 *
23
 * @author Melech Mizrachi
24
 */
25
class SqlInsertQueryBuilder extends SqlQueryBuilder implements Contract
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
    {
NEW
59
        $query = Statement::INSERT
×
60
            . ' ' . Statement::INTO
×
NEW
61
            . " $this->from"
×
NEW
62
            . $this->getAliasQuery();
×
63

NEW
64
        $columns = [];
×
NEW
65
        $values  = [];
×
66

NEW
67
        foreach ($this->values as $value) {
×
NEW
68
            $columns[] = $value->name;
×
NEW
69
            $values[]  = (string) $value;
×
70
        }
71

NEW
72
        $columns = implode(', ', $columns);
×
NEW
73
        $values  = implode(', ', $values);
×
74

NEW
75
        return $query
×
NEW
76
            . " ($columns)"
×
77
            . ' ' . Statement::VALUES
×
NEW
78
            . " ($values)"
×
NEW
79
            . $this->getWhereQuery()
×
NEW
80
            . $this->getJoinQuery();
×
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