Skip to content

Commit ea12ddc

Browse files
committed
feat: Add shorthand method to get subfield value
1 parent ccd3012 commit ea12ddc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Fields/Field.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,10 @@ public function __get($key)
2323
return call_user_func(array($this, $method));
2424
}
2525
}
26+
27+
public function sf($code)
28+
{
29+
$x = $this->getSubfield($code);
30+
return $x->getData();
31+
}
2632
}

tests/FieldsTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public function testIsbn()
1818
</record>';
1919

2020
$record = Record::fromString($source);
21-
$this->assertEquals(array('8200424421'), $record->isbns);
21+
$this->assertEquals(['8200424421'], $record->isbns);
22+
$this->assertEquals('Nkr 98.00', $record->isbns[0]->sf('c'));
2223
}
2324

2425
public function test020withoutA()

0 commit comments

Comments
 (0)