File tree Expand file tree Collapse file tree 3 files changed +25
-5
lines changed Expand file tree Collapse file tree 3 files changed +25
-5
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Scriptotek \Marc ;
4
+
5
+ class Marc21
6
+ {
7
+ // MARC21 record types
8
+ const AUTHORITY = 'Authority ' ;
9
+ const BIBLIOGRAPHIC = 'Bibliographic ' ;
10
+ const HOLDINGS = 'Holdings ' ;
11
+ }
Original file line number Diff line number Diff line change @@ -60,6 +60,14 @@ public static function fromString($data)
60
60
* Determine if record is a bibliographic, authority or holdings record
61
61
*************************************************************************/
62
62
63
+ /**
64
+ * Get the record type based on the value of LDR/6. Returns any of
65
+ * the Marc21::BIBLIOGRAPHIC, Marc21::AUTHORITY or Marc21::HOLDINGS
66
+ * constants.
67
+ *
68
+ * @return string
69
+ * @throws ErrorException
70
+ */
63
71
public function getType ()
64
72
{
65
73
$ leader = $ this ->record ->getLeader ();
@@ -80,14 +88,14 @@ public function getType()
80
88
case 'p ' : // Mixed materials
81
89
case 'r ' : // Three-dimensional artifact or naturally occurring object
82
90
case 't ' : // Manuscript language material
83
- return ' Bibliographic ' ;
91
+ return Marc21:: BIBLIOGRAPHIC ;
84
92
case 'z ' :
85
- return ' Authority ' ;
93
+ return Marc21:: AUTHORITY ;
86
94
case 'u ' : // Unknown
87
95
case 'v ' : // Multipart item holdings
88
96
case 'x ' : // Single-part item holdings
89
97
case 'y ' : // Serial item holdings
90
- return ' Holdings ' ;
98
+ return Marc21:: HOLDINGS ;
91
99
default :
92
100
throw new \ErrorException ('Unknown record type. ' );
93
101
}
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ use Scriptotek \Marc \Marc21 ;
3
4
use Scriptotek \Marc \Record ;
4
5
5
6
class RecordTest extends \PHPUnit_Framework_TestCase
@@ -69,7 +70,7 @@ public function testRecordTypeBiblio()
69
70
</record> ' ;
70
71
71
72
$ record = Record::fromString ($ source );
72
- $ this ->assertEquals (' Bibliographic ' , $ record ->type );
73
+ $ this ->assertEquals (Marc21:: BIBLIOGRAPHIC , $ record ->type );
73
74
}
74
75
75
76
public function testRecordTypeAuthority ()
@@ -80,6 +81,6 @@ public function testRecordTypeAuthority()
80
81
</record> ' ;
81
82
82
83
$ record = Record::fromString ($ source );
83
- $ this ->assertEquals (' Authority ' , $ record ->type );
84
+ $ this ->assertEquals (Marc21:: AUTHORITY , $ record ->type );
84
85
}
85
86
}
You can’t perform that action at this time.
0 commit comments