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

brick / structured-data / 17475567799

04 Sep 2025 08:14PM UTC coverage: 77.67%. Remained the same
17475567799

push

github

BenMorel
Apply coding standard

14 of 15 new or added lines in 5 files covered. (93.33%)

59 existing lines in 7 files now uncovered.

240 of 309 relevant lines covered (77.67%)

1.84 hits per line

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

85.71
/src/Item.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Brick\StructuredData;
6

7
/**
8
 * An item, such as a Thing in schema.org's vocabulary.
9
 */
10
final class Item
11
{
12
    /**
13
     * The global identifier of the item, if any.
14
     */
15
    private readonly ?string $id;
16

17
    /**
18
     * The types this Item implements, as URLs.
19
     *
20
     * @var string[]
21
     */
22
    private readonly array $types;
23

24
    /**
25
     * The properties, as a map of property name to list of values.
26
     *
27
     * @var array<string, array<Item|string>>
28
     */
29
    private array $properties = [];
30

31
    /**
32
     * Item constructor.
33
     *
34
     * @param string|null $id       An optional global identifier for the item.
35
     * @param string      ...$types The types this Item implements, as URLs, e.g. http://schema.org/Product .
36
     */
37
    public function __construct(?string $id, string ...$types)
38
    {
39
        $this->id = $id;
5✔
40
        $this->types = $types;
5✔
41
    }
42

43
    /**
44
     * Returns the global identifier of the item, if any.
45
     */
46
    public function getId(): ?string
47
    {
48
        return $this->id;
5✔
49
    }
50

51
    /**
52
     * Returns the list of types this Item implements.
53
     *
54
     * Each type is represented as a URL, e.g. http://schema.org/Product .
55
     *
56
     * @return string[]
57
     */
58
    public function getTypes(): array
59
    {
60
        return $this->types;
5✔
61
    }
62

63
    /**
64
     * Returns a map of property name to list of values.
65
     *
66
     * Property names are represented as URLs, e.g. http://schema.org/price .
67
     * Values are a list of Item instances or plain strings.
68
     *
69
     * @return array<string, array<Item|string>>
70
     */
71
    public function getProperties(): array
72
    {
73
        return $this->properties;
5✔
74
    }
75

76
    /**
77
     * Returns a list of values for the given property.
78
     *
79
     * The result is a list of Item instances or plain strings.
80
     * If the property does not exist, an empty array is returned.
81
     *
82
     * @return array<Item|string>
83
     */
84
    public function getProperty(string $name): array
85
    {
UNCOV
86
        return $this->properties[$name] ?? [];
×
87
    }
88

89
    public function addProperty(string $name, Item|string $value): void
90
    {
91
        $this->properties[$name][] = $value;
5✔
92
    }
93
}
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