-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from beatrycze-volk/related-item
Make `RelatedItem` to extend `ModsReader`
- Loading branch information
Showing
5 changed files
with
102 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright (C) 2024 Saxon State and University Library Dresden | ||
* | ||
* This file is part of the php-mods-reader. | ||
* | ||
* @license GNU General Public License version 3 or later. | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Slub\Mods\Attribute\Common; | ||
|
||
/** | ||
* Trait for two general types of attributes | ||
*/ | ||
trait Attribute | ||
{ | ||
|
||
/** | ||
* Get the string value of attribute. | ||
* | ||
* @access protected | ||
* | ||
* @param string $attribute name | ||
* | ||
* @return string | ||
*/ | ||
protected function getStringAttribute($attribute): string | ||
{ | ||
if ($this->xml->attributes() != null) { | ||
$value = $this->xml->attributes()->$attribute; | ||
|
||
if (!empty($value)) { | ||
return $value; | ||
} | ||
} | ||
return ''; | ||
} | ||
|
||
/** | ||
* Get the int value of attribute. | ||
* | ||
* @access protected | ||
* | ||
* @param string $attribute name | ||
* | ||
* @return int | ||
*/ | ||
protected function getIntAttribute($attribute): int | ||
{ | ||
if ($this->xml->attributes() != null) { | ||
$value = $this->xml->attributes()->$attribute; | ||
|
||
if (!empty($value)) { | ||
return (int) $value; | ||
} | ||
} | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters