Skip to content

Commit 2d570c8

Browse files
committed
Merge pull request #4 from cKlee/master
added charLength for offsetExists
2 parents 1eb0d45 + 1f4e41f commit 2d570c8

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

Field.php

+2
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,8 @@ public function offsetExists($offset)
553553
break;
554554
case 'charEnd': return isset($this->charEnd);
555555
break;
556+
case 'charLength': return !is_null($this->getCharLength());
557+
break;
556558
case 'indicator1': return isset($this->indicator1);
557559
break;
558560
case 'indicator2': return isset($this->indicator2);

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ For currently supported version of **MARCspec - A common MARC record path langua
88

99
Installation can be done by using [composer](https://getcomposer.org/doc/00-intro.md)
1010

11-
```
11+
```php
1212
{
1313
"require": {
1414
"ck/php-marcspec": "1.*"

Subfield.php

+3
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,9 @@ public function offsetExists($offset)
397397

398398
case 'charEnd': return isset($this->charEnd);
399399
break;
400+
401+
case 'charLength': return !is_null($this->getCharLength());
402+
break;
400403

401404
case 'subSpecs': return (0 < count($this->subSpecs)) ? true : false;
402405
break;

Test/FieldTest.php

-22
Original file line numberDiff line numberDiff line change
@@ -196,28 +196,6 @@ public function testInvalidFieldSpec34()
196196
public function testInvalidFieldSpec35()
197197
{
198198
$this->fieldspec('245___');
199-
}
200-
201-
/**
202-
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
203-
*/
204-
public function testInvalidFieldSpec37()
205-
{
206-
$this->fieldspec('245_1+');
207-
}
208-
/**
209-
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
210-
*/
211-
public function testInvalidFieldSpec38()
212-
{
213-
$this->fieldspec('245_123');
214-
}
215-
/**
216-
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
217-
*/
218-
public function testInvalidFieldSpec39()
219-
{
220-
$this->fieldspec('245_$');
221199
}
222200

223201
/**

Test/MarcSpecTest.php

+18
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,24 @@ public function testIteration()
214214

215215

216216
}
217+
218+
public function testOffsets()
219+
{
220+
$ms = $this->marcspec('LDR/0-3');
221+
$this->assertTrue($ms['field']->offsetExists('charLength'));
222+
223+
$ms = $this->marcspec('LDR/0-#');
224+
$this->assertFalse($ms['field']->offsetExists('charLength'));
225+
226+
$ms = $this->marcspec('245$a/0-3');
227+
$this->assertTrue($ms['a'][0]->offsetExists('charLength'));
228+
229+
$ms = $this->marcspec('245$a/#-3');
230+
$this->assertTrue($ms['a'][0]->offsetExists('charLength'));
231+
232+
$ms = $this->marcspec('245$a/0-#');
233+
$this->assertFalse($ms['a'][0]->offsetExists('charLength'));
234+
}
217235

218236

219237
}

0 commit comments

Comments
 (0)