Skip to content

Commit 544f4d4

Browse files
committed
Cleanup
1 parent 464d118 commit 544f4d4

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

src/Fields/Subject.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ public function getControlNumber($value='')
3939
return $this->field->getSubfield('0');
4040
}
4141

42+
/**
43+
* Returns the title of the record (245 $a, $b, $n and $p).
44+
* - Joins the subfields by colon if no ISBD marker present at the end of $a
45+
* - Removes trailing '/'
46+
* - See tests/TitleFieldTest.php for more info.
47+
*/
4248
public function __toString()
4349
{
4450
$parts = array();

src/Fields/Title.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44

55
class Title extends Field implements FieldInterface
66
{
7+
78
/**
8-
* See tests/TitleFieldTest.php for more info.
9+
* Returns the string representation $a, $b, $n and $p).
10+
* - Joins the subfields by colon if no ISBD marker present at the end of $a
11+
* - Removes trailing '/'
12+
* - See tests/TitleFieldTest.php for more info.
913
*/
1014
public function __toString()
1115
{

src/Record.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ public static function fromString($data)
2424
{
2525
$collection = Collection::fromString($data);
2626

27-
return $collection->records->toArray()[0];
27+
$recs = $collection->records->toArray();
28+
if (!count($recs)) {
29+
throw new \ErrorException('Record not found');
30+
}
31+
32+
return $recs[0];
2833
}
2934

3035
/*************************************************************************
@@ -93,11 +98,11 @@ public function getSubjects($vocabulary = null, $type = null)
9398
'653' => 'uncontrolled', # Index Term - Uncontrolled
9499
// 654 : Subject Added Entry - Faceted Topical Terms
95100
'655' => 'form', # Index Term - Genre/Form
96-
// 657 - Index Term - Function (R) Full | Concise
97-
// 658 - Index Term - Curriculum Objective (R) Full | Concise
98-
// 662 - Subject Added Entry - Hierarchical Place Name (R) Full | Concise
99-
// 69X - Local Subject Access Fields (R) Full | Concise
100101
'656' => 'occupation', # Index Term - Occupation
102+
// 657 - Index Term - Function
103+
// 658 - Index Term - Curriculum Objective
104+
// 662 - Subject Added Entry - Hierarchical Place Name
105+
// 69X - Local Subject Access Fields
101106
);
102107
foreach ($saf as $k => $v) {
103108
foreach ($this->record->getFields($k) as $field) { // or 655, 648, etc.
@@ -156,4 +161,5 @@ public function __toString()
156161
{
157162
return strval($this->record);
158163
}
164+
159165
}

0 commit comments

Comments
 (0)