xref: /dokuwiki/vendor/simplepie/simplepie/src/Author.php (revision 8e88a29b81301f78509349ab1152bb09c229123e)
1<?php
2
3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
4// SPDX-License-Identifier: BSD-3-Clause
5
6declare(strict_types=1);
7
8namespace SimplePie;
9
10/**
11 * Manages all author-related data
12 *
13 * Used by {@see Item::get_author()} and {@see SimplePie::get_authors()}
14 *
15 * This class can be overloaded with {@see SimplePie::set_author_class()}
16 */
17class Author
18{
19    /**
20     * Author's name
21     *
22     * @var ?string
23     * @see get_name()
24     */
25    public $name;
26
27    /**
28     * Author's link
29     *
30     * @var ?string
31     * @see get_link()
32     */
33    public $link;
34
35    /**
36     * Author's email address
37     *
38     * @var ?string
39     * @see get_email()
40     */
41    public $email;
42
43    /**
44     * Constructor, used to input the data
45     */
46    public function __construct(
47        ?string $name = null,
48        ?string $link = null,
49        ?string $email = null
50    ) {
51        $this->name = $name;
52        $this->link = $link;
53        $this->email = $email;
54    }
55
56    /**
57     * String-ified version
58     *
59     * @return string
60     */
61    public function __toString()
62    {
63        // There is no $this->data here
64        return md5(serialize($this));
65    }
66
67    /**
68     * Author's name
69     *
70     * @return string|null
71     */
72    public function get_name()
73    {
74        if ($this->name !== null) {
75            return $this->name;
76        }
77
78        return null;
79    }
80
81    /**
82     * Author's link
83     *
84     * @return string|null
85     */
86    public function get_link()
87    {
88        if ($this->link !== null) {
89            return $this->link;
90        }
91
92        return null;
93    }
94
95    /**
96     * Author's email address
97     *
98     * @return string|null
99     */
100    public function get_email()
101    {
102        if ($this->email !== null) {
103            return $this->email;
104        }
105
106        return null;
107    }
108}
109
110class_alias('SimplePie\Author', 'SimplePie_Author');
111