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

RonasIT / laravel-entity-generator / 21166733718

20 Jan 2026 09:43AM UTC coverage: 99.432% (-0.6%) from 100.0%
21166733718

Pull #241

github

web-flow
Merge 2b61df918 into 962b971b7
Pull Request #241: [239]: append field modifiers instead of uppercase options

165 of 167 new or added lines in 17 files covered. (98.8%)

4 existing lines in 2 files now uncovered.

1051 of 1057 relevant lines covered (99.43%)

11.39 hits per line

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

95.65
/src/Collections/FieldsCollection.php
1
<?php
2

3
namespace RonasIT\Support\Collections;
4

5
use Countable;
6
use Illuminate\Support\Arr;
7
use Illuminate\Support\Collection;
8
use IteratorAggregate;
9
use RonasIT\Support\Enums\FieldModifierEnum;
10
use RonasIT\Support\Enums\FieldTypeEnum;
11
use RonasIT\Support\ValueObjects\Field;
12
use Traversable;
13

14
final readonly class FieldsCollection implements Countable, IteratorAggregate
15
{
16
    private Collection $fields;
17

18
    public function __construct(iterable $fields = [])
19
    {
20
        $this->fields = collect($fields);
38✔
21
    }
22

23
    public function getIterator(): Traversable
24
    {
25
        return $this->fields->getIterator();
23✔
26
    }
27

28
    public function count(): int
29
    {
NEW
30
        return $this->fields->count();
×
31
    }
32

33
    public function merge(array $newFields): self
34
    {
35
        return new self($this->fields->concat($newFields));
31✔
36
    }
37

38
    public function getFields(): array
39
    {
40
        return $this->fields->all();
13✔
41
    }
42

43
    public function replaceFieldModifier(
44
        FieldTypeEnum $type,
45
        FieldModifierEnum $originalModifier,
46
        FieldModifierEnum $newModifier,
47
    ): self {
48
        $replaceModifierCallback = fn (array $modifiers) => Arr::map(
7✔
49
            array: $modifiers,
7✔
50
            callback: fn ($modifier) => ($modifier === $originalModifier) ? $newModifier : $modifier,
7✔
51
        );
7✔
52

53
        $fields = $this->updateModifiersByFieldType($type, $replaceModifierCallback);
7✔
54

55
        return new self($fields);
7✔
56
    }
57

58
    public function removeFieldModifier(FieldTypeEnum $type, FieldModifierEnum $removeModifier): self
59
    {
60
        $removeModifierCallback = fn (array $modifiers) => Arr::reject(
8✔
61
            array: $modifiers,
8✔
62
            callback: fn ($modifier) => $removeModifier === $modifier,
8✔
63
        );
8✔
64

65
        $fields = $this->updateModifiersByFieldType($type, $removeModifierCallback);
8✔
66

67
        return new self($fields);
8✔
68
    }
69

70
    public function removeFieldsByType(FieldTypeEnum $type): self
71
    {
72
        $fields = $this->fields->filter(fn (Field $field) => $field->type !== $type);
7✔
73

74
        return new self($fields);
7✔
75
    }
76

77
    public function getFieldsByType(FieldTypeEnum $type): array
78
    {
79
        return $this->fields->where('type', $type)->all();
13✔
80
    }
81

82
    protected function updateModifiersByFieldType(FieldTypeEnum $type, callable $callback): Collection
83
    {
84
        return $this
9✔
85
            ->fields
9✔
86
            ->map(fn (Field $field) => ($field->type === $type) ? $field->updateModifiers($callback) : $field);
9✔
87
    }
88
}
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