Skip to content

Commit 23ea68f

Browse files
Initial commit
0 parents  commit 23ea68f

File tree

86 files changed

+7599
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+7599
-0
lines changed

.github/phpstan.neon

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: 5
3+
paths:
4+
- ../src/
5+
treatPhpDocTypesAsCertain: false

.github/workflows/phpstan.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: PHPStan
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
phpstan:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Install dependencies
17+
uses: php-actions/composer@v6
18+
with:
19+
command: update
20+
php_version: "7.4"
21+
22+
- name: PHPStan Static Analysis
23+
uses: php-actions/phpstan@v3
24+
with:
25+
configuration: ./.github/phpstan.neon

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.buildpath
2+
.project
3+
.settings/
4+
/vendor/
5+
/composer.lock
6+
/composer.phar

LICENSE

+674
Large diffs are not rendered by default.

README.md

Whitespace-only changes.

composer.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "slub/php-mods-reader",
3+
"description": "Read MODS metadata into PHP objects that offer some convenient data extraction methods",
4+
"type": "library",
5+
"keywords": [
6+
"mods",
7+
"mods-reader"
8+
],
9+
"require": {
10+
"php": ">=7.4"
11+
},
12+
"require-dev": {
13+
"phpunit/phpunit": "~7.5"
14+
},
15+
"autoload": {
16+
"psr-4": {
17+
"Slub\\Mods\\": "src/Mods/"
18+
}
19+
},
20+
"autoload-dev": {
21+
"psr-4": {
22+
"Slub\\Mods\\": "tests/Mods/"
23+
}
24+
},
25+
"minimum-stability": "stable",
26+
"license": "GPL-3.0-or-later",
27+
"authors": [
28+
{
29+
"name": "Beatrycze Volk",
30+
"email": "[email protected]",
31+
"role": "Developer"
32+
}
33+
]
34+
}

phpunit.xml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="vendor/autoload.php" colors="true">
3+
<testsuites>
4+
<testsuite name="MODS Reader Test Suite">
5+
<directory>./tests/Mods/</directory>
6+
<directory>./tests/Mods/Context</directory>
7+
</testsuite>
8+
</testsuites>
9+
<filter>
10+
<whitelist processUncoveredFilesFromWhitelist="true">
11+
<directory suffix=".php">src</directory>
12+
</whitelist>
13+
</filter>
14+
</phpunit>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/**
4+
* Copyright (C) 2024 Saxon State and University Library Dresden
5+
*
6+
* This file is part of the php-mods-reader.
7+
*
8+
* @license GNU General Public License version 3 or later.
9+
* For the full copyright and license information, please read the
10+
* LICENSE.txt file that was distributed with this source code.
11+
*/
12+
13+
namespace Slub\Mods\Attribute\Common;
14+
15+
trait AuthorityAttribute
16+
{
17+
18+
/**
19+
* Get the value of authority
20+
*
21+
* @return string
22+
*/
23+
public function getAuthority(): string
24+
{
25+
return $this->getStringAttribute('authority');
26+
}
27+
28+
/**
29+
* Get the value of authorityURI
30+
*
31+
* @access public
32+
*
33+
* @return string
34+
*/
35+
public function getAuthorityURI(): string
36+
{
37+
return $this->getStringAttribute('authorityURI');
38+
}
39+
40+
/**
41+
* Get the value of valueURI
42+
*
43+
* @access public
44+
*
45+
* @return string
46+
*/
47+
public function getValueURI(): string
48+
{
49+
return $this->getStringAttribute('valueURI');
50+
}
51+
}
+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?php
2+
3+
/**
4+
* Copyright (C) 2024 Saxon State and University Library Dresden
5+
*
6+
* This file is part of the php-mods-reader.
7+
*
8+
* @license GNU General Public License version 3 or later.
9+
* For the full copyright and license information, please read the
10+
* LICENSE.txt file that was distributed with this source code.
11+
*/
12+
13+
namespace Slub\Mods\Attribute\Common;
14+
15+
trait DateAttribute
16+
{
17+
18+
/**
19+
* @access private
20+
* @var array
21+
*/
22+
private array $allowedEncodings = [
23+
'w3cdtf',
24+
'iso8601',
25+
'marc',
26+
'edtf',
27+
'temper'
28+
];
29+
30+
/**
31+
* @access private
32+
* @var array
33+
*/
34+
private array $allowedPoints = [
35+
'start',
36+
'end'
37+
];
38+
39+
/**
40+
* @access private
41+
* @var array
42+
*/
43+
private array $allowedQualifiers = [
44+
'approximate',
45+
'inferred',
46+
'questionable'
47+
];
48+
49+
/**
50+
* Get the value of encoding
51+
*
52+
* @access public
53+
*
54+
* @return string
55+
*/
56+
public function getEncoding(): string
57+
{
58+
return $this->getStringAttribute('encoding');
59+
}
60+
61+
/**
62+
* Get the value of point
63+
*
64+
* @access public
65+
*
66+
* @return string
67+
*/
68+
public function getPoint(): string
69+
{
70+
return $this->getStringAttribute('point');
71+
}
72+
73+
/**
74+
* Get the value of keyDate
75+
*
76+
* @access public
77+
*
78+
* @return bool
79+
*/
80+
public function isKeyDate(): bool
81+
{
82+
return !empty($this->xml->attributes()->keyDate);
83+
}
84+
85+
/**
86+
* Get the value of qualifier
87+
*
88+
* @access public
89+
*
90+
* @return string
91+
*/
92+
public function getQualifier(): string
93+
{
94+
return $this->getStringAttribute('qualifier');
95+
}
96+
97+
/**
98+
* Get the value of calendar
99+
*
100+
* @access public
101+
*
102+
* @return string
103+
*/
104+
public function getCalendar(): string
105+
{
106+
return $this->getStringAttribute('calendar');
107+
}
108+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
/**
4+
* Copyright (C) 2024 Saxon State and University Library Dresden
5+
*
6+
* This file is part of the php-mods-reader.
7+
*
8+
* @license GNU General Public License version 3 or later.
9+
* For the full copyright and license information, please read the
10+
* LICENSE.txt file that was distributed with this source code.
11+
*/
12+
13+
namespace Slub\Mods\Attribute\Common;
14+
15+
trait LanguageAttribute
16+
{
17+
18+
/**
19+
* Get the value of lang
20+
*
21+
* @access public
22+
*
23+
* @return string
24+
*/
25+
public function getLang(): string
26+
{
27+
return $this->getStringAttribute('lang');
28+
}
29+
30+
/**
31+
* Get the value of xmlLang
32+
*
33+
* @access public
34+
*
35+
* @return string
36+
*/
37+
public function getXmlLang(): string
38+
{
39+
return $this->getStringAttribute('xmlLang');
40+
}
41+
42+
/**
43+
* Get the value of script
44+
*
45+
* @access public
46+
*
47+
* @return string
48+
*/
49+
public function getScript(): string
50+
{
51+
return $this->getStringAttribute('script');
52+
}
53+
54+
/**
55+
* Get the value of transliteration
56+
*
57+
* @access public
58+
*
59+
* @return string
60+
*/
61+
public function getTransliteration(): string
62+
{
63+
return $this->getStringAttribute('transliteration');
64+
}
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/**
4+
* Copyright (C) 2024 Saxon State and University Library Dresden
5+
*
6+
* This file is part of the php-mods-reader.
7+
*
8+
* @license GNU General Public License version 3 or later.
9+
* For the full copyright and license information, please read the
10+
* LICENSE.txt file that was distributed with this source code.
11+
*/
12+
13+
namespace Slub\Mods\Attribute\Common\Linking;
14+
15+
trait AltRepGroupAttribute
16+
{
17+
18+
/**
19+
* Get used to link alternative representations of the same element content, for different languages, scripts, transliterations, and translations
20+
*
21+
* @access public
22+
*
23+
* @return string
24+
*/
25+
public function getAltRepGroup(): string
26+
{
27+
return $this->getStringAttribute('altRepGroup');
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/**
4+
* Copyright (C) 2024 Saxon State and University Library Dresden
5+
*
6+
* This file is part of the php-mods-reader.
7+
*
8+
* @license GNU General Public License version 3 or later.
9+
* For the full copyright and license information, please read the
10+
* LICENSE.txt file that was distributed with this source code.
11+
*/
12+
13+
namespace Slub\Mods\Attribute\Common\Linking;
14+
15+
trait IdAttribute
16+
{
17+
18+
/**
19+
* Get the value of id
20+
*
21+
* @access public
22+
*
23+
* @return string
24+
*/
25+
public function getId(): string
26+
{
27+
return $this->getStringAttribute('ID');
28+
}
29+
30+
/**
31+
* Get the value of idRef
32+
*
33+
* @access public
34+
*
35+
* @return string
36+
*/
37+
public function getIdRef(): string
38+
{
39+
return $this->getStringAttribute('IDREF');
40+
}
41+
}

0 commit comments

Comments
 (0)