Skip to content

Commit 7c72521

Browse files
rudolfbykerdanmichaelo
authored andcommitted
Properly document the Record class.
1 parent e363c3a commit 7c72521

File tree

1 file changed

+51
-8
lines changed

1 file changed

+51
-8
lines changed

src/Record.php

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ class Record implements JsonSerializable
4545
{
4646
use MagicAccess;
4747

48+
/**
49+
* The record that is being wrapped.
50+
*
51+
* @var \File_MARC_Record
52+
*/
4853
protected $record;
4954

5055
/**
@@ -91,6 +96,17 @@ public function getField($spec = null, $pcre = null)
9196
return null;
9297
}
9398

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+
*/
94110
public function getFields($spec = null, $pcre = null)
95111
{
96112
return array_values(array_map(function (File_MARC_Field $field) {
@@ -103,11 +119,14 @@ public function getFields($spec = null, $pcre = null)
103119
*************************************************************************/
104120

105121
/**
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.
107123
*
108-
* @param $filename
124+
* @param string $filename
125+
* The name of the file containing the MARC records.
109126
* @return BibliographicRecord|HoldingsRecord|AuthorityRecord
127+
* A wrapped MARC record.
110128
* @throws RecordNotFound
129+
* When the file does not contain a MARC record.
111130
*/
112131
public static function fromFile($filename)
113132
{
@@ -121,11 +140,14 @@ public static function fromFile($filename)
121140
}
122141

123142
/**
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.
125144
*
126-
* @param $data
145+
* @param string $data
146+
* The string in which to look for MARC records.
127147
* @return BibliographicRecord|HoldingsRecord|AuthorityRecord
148+
* A wrapped MARC record.
128149
* @throws RecordNotFound
150+
* When the string does not contain a MARC record.
129151
*/
130152
public static function fromString($data)
131153
{
@@ -143,7 +165,8 @@ public static function fromString($data)
143165
*************************************************************************/
144166

145167
/**
146-
* @param string $spec The MARCspec string
168+
* @param string $spec
169+
* The MARCspec string
147170
* @return QueryResult
148171
*/
149172
public function query($spec)
@@ -156,11 +179,11 @@ public function query($spec)
156179
*************************************************************************/
157180

158181
/**
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.
162183
*
163184
* @return string
185+
* Any of the Marc21::BIBLIOGRAPHIC, Marc21::AUTHORITY or Marc21::HOLDINGS
186+
* constants.
164187
* @throws UnknownRecordType
165188
*/
166189
public function getType()
@@ -187,6 +210,11 @@ public function getId()
187210
* Support methods
188211
*************************************************************************/
189212

213+
/**
214+
* Convert the MARC record into an array structure fit for `json_encode`.
215+
*
216+
* @return array
217+
*/
190218
public function jsonSerialize()
191219
{
192220
$o = [];
@@ -213,11 +241,26 @@ public function jsonSerialize()
213241
return $o;
214242
}
215243

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+
*/
216254
public function __call($name, $args)
217255
{
218256
return call_user_func_array([$this->record, $name], $args);
219257
}
220258

259+
/**
260+
* Get a string representation of this record.
261+
*
262+
* @return string
263+
*/
221264
public function __toString()
222265
{
223266
return strval($this->record);

0 commit comments

Comments
 (0)