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

api-platform / core / 3713134090

pending completion
3713134090

Pull #5254

github

GitHub
Merge b2ec54b3c into ac711530f
Pull Request #5254: [OpenApi] Add ApiResource::openapi and deprecate openapiContext

197 of 197 new or added lines in 5 files covered. (100.0%)

7493 of 12362 relevant lines covered (60.61%)

67.56 hits per line

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

67.31
/src/Metadata/Link.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Metadata;
15

16
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::TARGET_PARAMETER)]
17
final class Link
18
{
19
    public function __construct(private ?string $parameterName = null, private ?string $fromProperty = null, private ?string $toProperty = null, private ?string $fromClass = null, private ?string $toClass = null, private ?array $identifiers = null, private ?bool $compositeIdentifier = null, private ?string $expandedValue = null)
20
    {
21
        // For the inverse property shortcut
22
        if ($this->parameterName && class_exists($this->parameterName)) {
20✔
23
            $this->fromClass = $this->parameterName;
×
24
        }
25
    }
26

27
    public function getParameterName(): ?string
28
    {
29
        return $this->parameterName;
468✔
30
    }
31

32
    public function withParameterName(string $parameterName): self
33
    {
34
        $self = clone $this;
20✔
35
        $self->parameterName = $parameterName;
20✔
36

37
        return $self;
20✔
38
    }
39

40
    public function getFromClass(): ?string
41
    {
42
        return $this->fromClass;
497✔
43
    }
44

45
    public function withFromClass(string $fromClass): self
46
    {
47
        $self = clone $this;
20✔
48
        $self->fromClass = $fromClass;
20✔
49

50
        return $self;
20✔
51
    }
52

53
    public function getToClass(): ?string
54
    {
55
        return $this->toClass;
24✔
56
    }
57

58
    public function withToClass(string $toClass): self
59
    {
60
        $self = clone $this;
9✔
61
        $self->toClass = $toClass;
9✔
62

63
        return $self;
9✔
64
    }
65

66
    public function getFromProperty(): ?string
67
    {
68
        return $this->fromProperty;
225✔
69
    }
70

71
    public function withFromProperty(string $fromProperty): self
72
    {
73
        $self = $this;
9✔
74
        $self->fromProperty = $fromProperty;
9✔
75

76
        return $self;
9✔
77
    }
78

79
    public function getToProperty(): ?string
80
    {
81
        return $this->toProperty;
217✔
82
    }
83

84
    public function withToProperty(string $toProperty): self
85
    {
86
        $self = clone $this;
×
87
        $self->toProperty = $toProperty;
×
88

89
        return $self;
×
90
    }
91

92
    public function getIdentifiers(): ?array
93
    {
94
        return $this->identifiers;
495✔
95
    }
96

97
    public function withIdentifiers(array $identifiers): self
98
    {
99
        $self = clone $this;
20✔
100
        $self->identifiers = $identifiers;
20✔
101

102
        return $self;
20✔
103
    }
104

105
    public function getCompositeIdentifier(): ?bool
106
    {
107
        return $this->compositeIdentifier;
224✔
108
    }
109

110
    public function withCompositeIdentifier(bool $compositeIdentifier): self
111
    {
112
        $self = clone $this;
×
113
        $self->compositeIdentifier = $compositeIdentifier;
×
114

115
        return $self;
×
116
    }
117

118
    public function getExpandedValue(): ?string
119
    {
120
        return $this->expandedValue;
221✔
121
    }
122

123
    public function withExpandedValue(string $expandedValue): self
124
    {
125
        $self = clone $this;
×
126
        $self->expandedValue = $expandedValue;
×
127

128
        return $self;
×
129
    }
130

131
    public function withLink(self $link): self
132
    {
133
        $self = clone $this;
1✔
134

135
        if (!$self->getToProperty() && ($toProperty = $link->getToProperty())) {
1✔
136
            $self->toProperty = $toProperty;
1✔
137
        }
138

139
        if (!$self->getCompositeIdentifier() && ($compositeIdentifier = $link->getCompositeIdentifier())) {
1✔
140
            $self->compositeIdentifier = $compositeIdentifier;
×
141
        }
142

143
        if (!$self->getFromClass() && ($fromClass = $link->getFromClass())) {
1✔
144
            $self->fromClass = $fromClass;
×
145
        }
146

147
        if (!$self->getToClass() && ($toClass = $link->getToClass())) {
1✔
148
            $self->toClass = $toClass;
×
149
        }
150

151
        if (!$self->getIdentifiers() && ($identifiers = $link->getIdentifiers())) {
1✔
152
            $self->identifiers = $identifiers;
×
153
        }
154

155
        if (!$self->getFromProperty() && ($fromProperty = $link->getFromProperty())) {
1✔
156
            $self->fromProperty = $fromProperty;
×
157
        }
158

159
        if (!$self->getParameterName() && ($parameterName = $link->getParameterName())) {
1✔
160
            $self->parameterName = $parameterName;
×
161
        }
162

163
        if (!$self->getExpandedValue() && ($expandedValue = $link->getExpandedValue())) {
1✔
164
            $self->expandedValue = $expandedValue;
×
165
        }
166

167
        return $self;
1✔
168
    }
169
}
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