Commit 2ad6d4f7 authored by David Maus's avatar David Maus
Browse files

Fix E_STRICT compliance

parent de79875c
......@@ -59,9 +59,9 @@ class AuthorityRecord extends Record {
* @return string|null Pica production number or NULL if none exists
*/
public function getPPN () {
$ppnField = reset($this->getFields('003@/00'));
$ppnField = $this->getFirstMatchingField('003@/00');
if ($ppnField) {
$ppnSubfield = reset($ppnField->getSubfields('0'));
$ppnSubfield = $ppnField->getNthSubfield('0', 0);
if ($ppnSubfield) {
return $ppnSubfield->getValue();
}
......@@ -78,9 +78,9 @@ class AuthorityRecord extends Record {
* @return void
*/
public function setPPN ($ppn) {
$ppnField = reset($this->getFields('003@/00'));
$ppnField = $this->getFirstMatchingField('003@/00');
if ($ppnField) {
$ppnSubfield = reset($ppnField->getSubfields('0'));
$ppnSubfield = $ppnField->getNthSubfield('0', 0);
if ($ppnSubfield) {
$ppnSubfield->setValue($ppn);
} else {
......@@ -116,7 +116,7 @@ class AuthorityRecord extends Record {
protected function checkPPN () {
$ppnField = $this->getFields('003@/00');
if (count($ppnField) === 1) {
$ppnSubfield = reset(reset($ppnField)->getSubfields('0'));
$ppnSubfield = reset($ppnField)->getNthSubfield('0', 0);
if ($ppnSubfield) {
return true;
}
......@@ -133,7 +133,7 @@ class AuthorityRecord extends Record {
protected function checkType () {
$typeField = $this->getFields('002@/00');
if (count($typeField) === 1) {
$typeSubfield = reset(reset($typeField)->getSubfields('0'));
$typeSubfield = reset($typeField)->getNthSubfield('0', 0);
if ($typeSubfield) {
$typeCode = $typeSubfield->getValue();
if ($typeCode === 'T') {
......
......@@ -46,7 +46,7 @@ class CopyRecord extends Record {
/**
* Append a field to the copy record.
*
* You can only append field of level 2 to a copy record.
* You can only append field of level 2 to a copy record.
*
* @see Record::append()
*
......@@ -94,9 +94,9 @@ class CopyRecord extends Record {
* @return string Exemplar production number
*/
public function getEPN () {
$epnField = reset($this->getFields('203@'));
$epnField = $this->getFirstMatchingField('203@');
if ($epnField) {
$epnSubfield = reset($epnField->getSubfields('0'));
$epnSubfield = $epnField->getNthSubfield('0', 0);
if ($epnSubfield) {
return $epnSubfield->getValue();
}
......@@ -113,9 +113,9 @@ class CopyRecord extends Record {
* @return void
*/
public function setEPN ($epn) {
$epnField = reset($this->getFields('203@'));
$epnField = $this->getFirstMatchingField('203@');
if ($epnField) {
$epnSubfield = reset($epnField->getSubfields('0'));
$epnSubfield = $epnField->getNthSubfield('0', 0);
if ($epnSubfield) {
$epnSubfield->setValue($epn);
} else {
......
......@@ -111,9 +111,9 @@ class LocalRecord extends NestedRecord {
* @return integer|null ILN of the local record or NULL if none set
*/
public function getILN () {
$ilnField = reset($this->getFields('101@'));
$ilnField = $this->getFirstMatchingField('101@/00');
if ($ilnField) {
$ilnSubfield = reset($ilnField->getSubfields('a'));
$ilnSubfield = $ilnField->getNthSubfield('a', 0);
if ($ilnSubfield) {
return $ilnSubfield->getValue();
}
......
......@@ -61,7 +61,7 @@ abstract class Record {
$typePredicate = Field::match('002@/00');
foreach ($fields as $field) {
if ($typePredicate($field)) {
$typeSubfield = reset($field->getSubfields('0'));
$typeSubfield = $field->getNthSubfield('0', 0);
if ($typeSubfield) {
$type = $typeSubfield->getValue();
break;
......
......@@ -76,7 +76,8 @@ class TitleRecord extends NestedRecord {
$localRecord = new LocalRecord(array($field));
$this->addLocalRecord($localRecord);
} else {
$localRecord = end($this->getLocalRecords());
$records = $this->getLocalRecords();
$localRecord = end($records);
if ($level === 1) {
$localRecord->append($field);
} else {
......@@ -145,9 +146,9 @@ class TitleRecord extends NestedRecord {
* @return string|null Pica production number or NULL if none exists
*/
public function getPPN () {
$ppnField = reset($this->getFields('003@/00'));
$ppnField = $this->getFirstMatchingField('003@/00');
if ($ppnField) {
$ppnSubfield = reset($ppnField->getSubfields('0'));
$ppnSubfield = $ppnField->getNthSubfield('0', 0);
if ($ppnSubfield) {
return $ppnSubfield->getValue();
}
......@@ -164,9 +165,9 @@ class TitleRecord extends NestedRecord {
* @return void
*/
public function setPPN ($ppn) {
$ppnField = reset($this->getFields('003@/00'));
$ppnField = $this->getFirstMatchingField('003@/00');
if ($ppnField) {
$ppnSubfield = reset($ppnField->getSubfields('0'));
$ppnSubfield = $ppnField->getNthSubfield('0', 0);
if ($ppnSubfield) {
$ppnSubfield->setValue($ppn);
} else {
......
......@@ -85,7 +85,8 @@ class AuthorityRecordTest extends \PHPUnit_FrameWork_TestCase {
$r->append($f);
$c = clone($r);
$this->assertNotSame($r, $c);
$this->assertNotSame($f, reset($c->getFields()));
$fields = $c->getFields();
$this->assertNotSame($f, reset($fields));
}
public function testIsInvalidEmptyField () {
......@@ -118,8 +119,9 @@ class AuthorityRecordTest extends \PHPUnit_FrameWork_TestCase {
$r = new AuthorityRecord(array(new Field('003@', 99, array(new Subfield('0', 'valid'))),
new Field('003@', 0, array(new Subfield('0', 'valid')))));
$r->sort();
$this->assertEquals('003@/00', reset($r->getFields('003@'))->getShorthand());
$this->assertEquals('003@/99', end($r->getFields('003@'))->getShorthand());
$fields = $r->getFields('003@');
$this->assertEquals('003@/00', reset($fields)->getShorthand());
$this->assertEquals('003@/99', end($fields)->getShorthand());
}
///
......
......@@ -55,9 +55,11 @@ class LocalRecordTest extends \PHPUnit_FrameWork_TestCase {
$b = new CopyRecord(array(new Field('200@', 99)));
$r->addCopyRecord($b);
$r->addCopyRecord($a);
$this->assertSame($b, reset($r->getCopyRecords()));
$c = $r->getCopyRecords();
$this->assertSame($b, reset($c));
$r->sort();
$this->assertSame($a, reset($r->getCopyRecords()));
$c = $r->getCopyRecords();
$this->assertSame($a, reset($c));
}
public function testGetILN () {
......
......@@ -27,7 +27,7 @@
namespace HAB\Pica\Record;
class TitleRecordTest extends \PHPUnit_FrameWork_TestCase {
public function testAppend () {
$r = new TitleRecord();
$r->append(new Field('003@', 0));
......@@ -47,7 +47,8 @@ class TitleRecordTest extends \PHPUnit_FrameWork_TestCase {
* @depends testAddLocalRecord
*/
public function testRemoveLocalRecord (TitleRecord $r) {
$l = end($r->getLocalRecords());
$l = $r->getLocalRecords();
$l = end($l);
$r->removeLocalRecord($l);
$this->assertEquals(0, count($r->getLocalRecords()));
}
......@@ -72,7 +73,7 @@ class TitleRecordTest extends \PHPUnit_FrameWork_TestCase {
$this->assertEquals(1, count($r->getLocalRecords()));
$fields []= new Field('101@', 0, array(new Subfield('a', 2)));
$r->setFields($fields);
$this->assertEquals(2, count($r->getLocalRecords()));
$this->assertEquals(2, count($r->getLocalRecords()));
}
public function testGetLocalRecordByILN () {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment