Skip to content

Commit

Permalink
Travis: Test with PHP 7.2 and 7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
danmichaelo committed Sep 13, 2019
1 parent 74652a3 commit 970e9e1
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ language: php

php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3

before_script:
- composer install --dev -o -n
Expand Down
88 changes: 88 additions & 0 deletions src/Fields/Corporation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

namespace Scriptotek\Marc\Fields;

use Scriptotek\Marc\Record;

class Corporation extends Field implements FieldInterface
{
/**
* @var array List of properties to be included when serializing the record using the `toArray()` method.
*/
public $properties = ['type', 'id', 'name', 'subordinate_unit', 'location', 'date', 'number', 'relationship'];

public static $headingComponentCodes = ['a', 'b', 'c', 'd', 'n'];

const MAIN_ENTRY= '110';
const ADDED_ENTRY = '710';

public static function get(Record $record)
{
$objs = [];

foreach (parent::makeFieldObjects($record, Person::MAIN_ENTRY) as $obj) {
$objs[] = $obj;
}

foreach (parent::makeFieldObjects($record, Person::ADDED_ENTRY) as $obj) {
$objs[] = $obj;
}

return $objs;
}

public function getType()
{
return $this->getTag();
}

/**
* Return the Authority record control number
*/
public function getId()
{
// preg_match('/^\((.+)\)(.+)$/', $sf0->getData(), $matches);
return $this->sf('0');
}

public function getName()
{
return $this->sf('a');
}

public function getSubordinateUnit()
{
return $this->sf('b');
}

public function getLocation()
{
return $this->sf('c');
}

public function getDate()
{
return $this->sf('d');
}

public function getNumber()
{
return $this->sf('n');
}

public function getRelationship()
{
return $this->sf('4');
}

public function __toString()
{
$out = [];
foreach ($this->getSubfields() as $sf) {
if (in_array($sf->getCode(), $this->headingComponentCodes)) {
$out[] = $sf->getData();
}
}
return str_replace('/ /', ' ', implode(' ', $out));
}
}

0 comments on commit 970e9e1

Please sign in to comment.