Skip to content

Commit fd2f16f

Browse files
committed
feat: Add descriptive cataloging form getter
1 parent 85fd59a commit fd2f16f

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/Marc21.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,12 @@ class Marc21
88
const AUTHORITY = 'Authority';
99
const BIBLIOGRAPHIC = 'Bibliographic';
1010
const HOLDINGS = 'Holdings';
11+
12+
// Descriptive cataloging forms
13+
const NON_ISBD = ' ';
14+
const AACR2 = 'a';
15+
const ISBD_PUNCTUATION_OMITTED = 'c';
16+
const ISBD_PUNCTUATION_INCLUDED = 'i';
17+
const NON_ISBD_PUNCTUATION_OMITTED = 'n';
18+
const UNKNOWN_CATALOGING_FORM = 'u';
1119
}

src/Record.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ public function getType()
106106
}
107107
}
108108

109+
/**
110+
* Get the descriptive cataloging form value from LDR/18. Returns any of
111+
* the constants Marc21::NON_ISBD, Marc21::AACR2, Marc21::ISBD_PUNCTUATION_OMITTED,
112+
* Marc21::ISBD_PUNCTUATION_INCLUDED, Marc21::NON_ISBD_PUNCTUATION_OMITTED
113+
* or Marc21::UNKNOWN_CATALOGING_FORM.
114+
*
115+
* @return string
116+
* @throws UnknownRecordType
117+
*/
118+
public function getCatalogingForm()
119+
{
120+
$leader = $this->record->getLeader();
121+
return substr($leader, 18, 1);
122+
}
123+
109124
/*************************************************************************
110125
* Helper methods for specific fields. Each of these are supported by
111126
* a class in src/Fields/

tests/RecordTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,15 @@ public function testRecordTypeAuthority()
8383
$record = Record::fromString($source);
8484
$this->assertEquals(Marc21::AUTHORITY, $record->type);
8585
}
86+
87+
public function testRecordTypeDescriptiveCatalogingForm()
88+
{
89+
$source = '<?xml version="1.0" encoding="UTF-8" ?>
90+
<record>
91+
<leader>99999cam a2299999 c 4500</leader>
92+
</record>';
93+
94+
$record = Record::fromString($source);
95+
$this->assertEquals(Marc21::ISBD_PUNCTUATION_OMITTED, $record->catalogingForm);
96+
}
8697
}

0 commit comments

Comments
 (0)