1: <?php
2: declare(strict_types=1);
3:
4: namespace om\ICal\Value;
5:
6: use om\ICal\Parameters;
7: use Stringable;
8:
9: /**
10: * LINK of a component (RFC 9253, section 8.2): a reference to external information,
11: * a serialization of a web link of RFC 8288.
12: */
13: final readonly class Link implements Stringable {
14: /**
15: * @param string $value a URI, an XML reference (a URI with an XPointer anchor) or a UID, see valueType()
16: */
17: public function __construct(
18: public string $value,
19: public Parameters $parameters,
20: ) {
21: }
22:
23: /**
24: * Type of the value: URI (default), XML-REFERENCE or UID.
25: */
26: public function valueType(): string {
27: return strtoupper($this->parameters->get('VALUE') ?? 'URI');
28: }
29:
30: /**
31: * Link relation type (LINKREL): a registered type such as "latest-version" or a URI; there is no default.
32: */
33: public function relation(): ?string {
34: return $this->parameters->get('LINKREL');
35: }
36:
37: /** Human-readable LABEL (the "title" of RFC 8288). */
38: public function label(): ?string {
39: return $this->parameters->get('LABEL');
40: }
41:
42: /** Media type of the target (FMTTYPE). */
43: public function mediaType(): ?string {
44: return $this->parameters->get('FMTTYPE');
45: }
46:
47: /** LANGUAGE of the target (the "hreflang" of RFC 8288). */
48: public function language(): ?string {
49: return $this->parameters->get('LANGUAGE');
50: }
51:
52: public function __toString(): string {
53: return $this->value;
54: }
55: }
56: