@@ -45,6 +45,11 @@ class Record implements JsonSerializable
45
45
{
46
46
use MagicAccess;
47
47
48
+ /**
49
+ * The record that is being wrapped.
50
+ *
51
+ * @var \File_MARC_Record
52
+ */
48
53
protected $ record ;
49
54
50
55
/**
@@ -91,6 +96,17 @@ public function getField($spec = null, $pcre = null)
91
96
return null ;
92
97
}
93
98
99
+ /**
100
+ * Find and wrap the specified MARC fields.
101
+ *
102
+ * @param string $spec
103
+ * The tag name.
104
+ * @param bool $pcre
105
+ * If true, match as a regular expression.
106
+ *
107
+ * @return \Scriptotek\Marc\Fields\Field[]
108
+ * An array of wrapped fields.
109
+ */
94
110
public function getFields ($ spec = null , $ pcre = null )
95
111
{
96
112
return array_values (array_map (function (File_MARC_Field $ field ) {
@@ -103,11 +119,14 @@ public function getFields($spec = null, $pcre = null)
103
119
*************************************************************************/
104
120
105
121
/**
106
- * Returns the first record found in the file $filename, or null if no records found .
122
+ * Returns the first record found in the file $filename.
107
123
*
108
- * @param $filename
124
+ * @param string $filename
125
+ * The name of the file containing the MARC records.
109
126
* @return BibliographicRecord|HoldingsRecord|AuthorityRecord
127
+ * A wrapped MARC record.
110
128
* @throws RecordNotFound
129
+ * When the file does not contain a MARC record.
111
130
*/
112
131
public static function fromFile ($ filename )
113
132
{
@@ -121,11 +140,14 @@ public static function fromFile($filename)
121
140
}
122
141
123
142
/**
124
- * Returns the first record found in the string $data, or null if no records found .
143
+ * Returns the first record found in the string $data.
125
144
*
126
- * @param $data
145
+ * @param string $data
146
+ * The string in which to look for MARC records.
127
147
* @return BibliographicRecord|HoldingsRecord|AuthorityRecord
148
+ * A wrapped MARC record.
128
149
* @throws RecordNotFound
150
+ * When the string does not contain a MARC record.
129
151
*/
130
152
public static function fromString ($ data )
131
153
{
@@ -143,7 +165,8 @@ public static function fromString($data)
143
165
*************************************************************************/
144
166
145
167
/**
146
- * @param string $spec The MARCspec string
168
+ * @param string $spec
169
+ * The MARCspec string
147
170
* @return QueryResult
148
171
*/
149
172
public function query ($ spec )
@@ -156,11 +179,11 @@ public function query($spec)
156
179
*************************************************************************/
157
180
158
181
/**
159
- * Get the record type based on the value of LDR/6. Returns any of
160
- * the Marc21::BIBLIOGRAPHIC, Marc21::AUTHORITY or Marc21::HOLDINGS
161
- * constants.
182
+ * Get the record type based on the value of LDR/6.
162
183
*
163
184
* @return string
185
+ * Any of the Marc21::BIBLIOGRAPHIC, Marc21::AUTHORITY or Marc21::HOLDINGS
186
+ * constants.
164
187
* @throws UnknownRecordType
165
188
*/
166
189
public function getType ()
@@ -187,6 +210,11 @@ public function getId()
187
210
* Support methods
188
211
*************************************************************************/
189
212
213
+ /**
214
+ * Convert the MARC record into an array structure fit for `json_encode`.
215
+ *
216
+ * @return array
217
+ */
190
218
public function jsonSerialize ()
191
219
{
192
220
$ o = [];
@@ -213,11 +241,26 @@ public function jsonSerialize()
213
241
return $ o ;
214
242
}
215
243
244
+ /**
245
+ * Delegate all unknown method calls to the wrapped record.
246
+ *
247
+ * @param string $name
248
+ * The name of the method being called.
249
+ * @param array $args
250
+ * The arguments being passed to the method.
251
+ *
252
+ * @return mixed
253
+ */
216
254
public function __call ($ name , $ args )
217
255
{
218
256
return call_user_func_array ([$ this ->record , $ name ], $ args );
219
257
}
220
258
259
+ /**
260
+ * Get a string representation of this record.
261
+ *
262
+ * @return string
263
+ */
221
264
public function __toString ()
222
265
{
223
266
return strval ($ this ->record );
0 commit comments