Skip to content

Commit 970e9e1

Browse files
committed
Travis: Test with PHP 7.2 and 7.3
1 parent 74652a3 commit 970e9e1

File tree

2 files changed

+90
-1
lines changed

2 files changed

+90
-1
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ language: php
22

33
php:
44
- 5.6
5-
- 7.0
65
- 7.1
6+
- 7.2
7+
- 7.3
78

89
before_script:
910
- composer install --dev -o -n

src/Fields/Corporation.php

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
namespace Scriptotek\Marc\Fields;
4+
5+
use Scriptotek\Marc\Record;
6+
7+
class Corporation extends Field implements FieldInterface
8+
{
9+
/**
10+
* @var array List of properties to be included when serializing the record using the `toArray()` method.
11+
*/
12+
public $properties = ['type', 'id', 'name', 'subordinate_unit', 'location', 'date', 'number', 'relationship'];
13+
14+
public static $headingComponentCodes = ['a', 'b', 'c', 'd', 'n'];
15+
16+
const MAIN_ENTRY= '110';
17+
const ADDED_ENTRY = '710';
18+
19+
public static function get(Record $record)
20+
{
21+
$objs = [];
22+
23+
foreach (parent::makeFieldObjects($record, Person::MAIN_ENTRY) as $obj) {
24+
$objs[] = $obj;
25+
}
26+
27+
foreach (parent::makeFieldObjects($record, Person::ADDED_ENTRY) as $obj) {
28+
$objs[] = $obj;
29+
}
30+
31+
return $objs;
32+
}
33+
34+
public function getType()
35+
{
36+
return $this->getTag();
37+
}
38+
39+
/**
40+
* Return the Authority record control number
41+
*/
42+
public function getId()
43+
{
44+
// preg_match('/^\((.+)\)(.+)$/', $sf0->getData(), $matches);
45+
return $this->sf('0');
46+
}
47+
48+
public function getName()
49+
{
50+
return $this->sf('a');
51+
}
52+
53+
public function getSubordinateUnit()
54+
{
55+
return $this->sf('b');
56+
}
57+
58+
public function getLocation()
59+
{
60+
return $this->sf('c');
61+
}
62+
63+
public function getDate()
64+
{
65+
return $this->sf('d');
66+
}
67+
68+
public function getNumber()
69+
{
70+
return $this->sf('n');
71+
}
72+
73+
public function getRelationship()
74+
{
75+
return $this->sf('4');
76+
}
77+
78+
public function __toString()
79+
{
80+
$out = [];
81+
foreach ($this->getSubfields() as $sf) {
82+
if (in_array($sf->getCode(), $this->headingComponentCodes)) {
83+
$out[] = $sf->getData();
84+
}
85+
}
86+
return str_replace('/ /', ' ', implode(' ', $out));
87+
}
88+
}

0 commit comments

Comments
 (0)