From 199626839496b236dc7381e0e9d6dfe96feaf08a Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Tue, 18 Jun 2024 18:36:27 +0200 Subject: [PATCH] Add function to get first value in `Element` class --- src/Mods/Element/Xml/Element.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Mods/Element/Xml/Element.php b/src/Mods/Element/Xml/Element.php index 64043fa..729af95 100644 --- a/src/Mods/Element/Xml/Element.php +++ b/src/Mods/Element/Xml/Element.php @@ -77,4 +77,19 @@ public function getValues(): array } return []; } -} \ No newline at end of file + + /** + * Get first value of the queried element. + * + * @access public + * + * @return mixed + */ + public function getFirstValue() + { + if ($this->exists()) { + return $this->values[0]; + } + return null; + } +}