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

diego-ninja / granite / 16608963009

29 Jul 2025 10:37PM UTC coverage: 50.423%. First build
16608963009

Pull #5

github

web-flow
Merge 43d8840d7 into 6a6caca51
Pull Request #5: code: adds phpstan level max, pint with per and github actions

321 of 632 new or added lines in 77 files covered. (50.79%)

1132 of 2245 relevant lines covered (50.42%)

9.88 hits per line

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

0.0
/src/Mapping/Attributes/MapCollection.php
1
<?php
2

3
namespace Ninja\Granite\Mapping\Attributes;
4

5
use Attribute;
6
use Ninja\Granite\Mapping\Contracts\Transformer;
7
use Ninja\Granite\Mapping\Transformers\CollectionTransformer;
8

9
/**
10
 * Attribute to configure collection mapping.
11
 */
12
#[Attribute(Attribute::TARGET_PROPERTY)]
13
readonly class MapCollection
14
{
15
    /**
16
     * @param class-string $destinationType The class name for collection items
17
     * @param bool $preserveKeys Whether to preserve array keys
18
     * @param bool $recursive Whether to handle nested collections recursively
19
     * @param mixed $itemTransformer Optional transformer for collection items
20
     */
21
    public function __construct(
×
22
        public string $destinationType,
23
        public bool $preserveKeys = false,
24
        public bool $recursive = false,
25
        public mixed $itemTransformer = null,
26
    ) {}
×
27

28
    /**
29
     * Create a collection transformer from this attribute.
30
     */
31
    public function createTransformer(mixed $mapper): Transformer
×
32
    {
33
        return new CollectionTransformer(
×
34
            $this->destinationType,
×
NEW
35
            is_object($mapper) && $mapper instanceof \Ninja\Granite\Mapping\Contracts\Mapper ? $mapper : null,
×
36
            $this->preserveKeys,
×
37
            $this->recursive,
×
NEW
38
            $this->itemTransformer,
×
39
        );
×
40
    }
41
}
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