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

tempestphp / tempest-framework / 14122915110

28 Mar 2025 05:56AM UTC coverage: 79.691% (+0.4%) from 79.334%
14122915110

Pull #1076

github

web-flow
Merge 2ccad9efc into 6af05d563
Pull Request #1076: refactor(database): remove `DatabaseModel` interface

558 of 571 new or added lines in 42 files covered. (97.72%)

1 existing line in 1 file now uncovered.

10767 of 13511 relevant lines covered (79.69%)

93.27 hits per line

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

89.47
/src/Tempest/Database/src/Builder/QueryBuilders/DeleteQueryBuilder.php
1
<?php
2

3
namespace Tempest\Database\Builder\QueryBuilders;
4

5
use Tempest\Database\Builder\ModelDefinition;
6
use Tempest\Database\Builder\TableDefinition;
7
use Tempest\Database\Query;
8
use Tempest\Database\QueryStatements\DeleteStatement;
9
use Tempest\Database\QueryStatements\WhereStatement;
10

11
use function Tempest\Database\model;
12

13
/**
14
 * @template TModelClass of object
15
 */
16
final class DeleteQueryBuilder
17
{
18
    private DeleteStatement $delete;
19

20
    private array $bindings = [];
21

22
    public function __construct(
5✔
23
        private string|object $model,
24
    ) {
25
        $table = ModelDefinition::tryFrom($this->model)?->getTableDefinition() ?? new TableDefinition($this->model);
5✔
26
        $this->delete = new DeleteStatement($table);
5✔
27

28
        if (model($this->model)->isObjectModel() && is_object($this->model)) {
5✔
29
            $this->where('`id` = :id', id: $this->model->id);
3✔
30
        }
31
    }
32

NEW
33
    public function execute(): void
×
34
    {
NEW
35
        $this->build()->execute();
×
36
    }
37

38
    public function allowAll(): self
1✔
39
    {
40
        $this->delete->allowAll = true;
1✔
41

42
        return $this;
1✔
43
    }
44

45
    public function where(string $where, mixed ...$bindings): self
4✔
46
    {
47
        $this->delete->where[] = new WhereStatement($where);
4✔
48

49
        $this->bind(...$bindings);
4✔
50

51
        return $this;
4✔
52
    }
53

54
    public function bind(mixed ...$bindings): self
4✔
55
    {
56
        $this->bindings = [...$this->bindings, ...$bindings];
4✔
57

58
        return $this;
4✔
59
    }
60

61
    public function build(): Query
5✔
62
    {
63
        return new Query($this->delete, $this->bindings);
5✔
64
    }
65
}
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