Skip to content

Commit 9d6cfec

Browse files
committed
Permitting strings for some inputs for convenience.
1 parent d1b519c commit 9d6cfec

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/org/nameapi/ontology/input/context/ContextBuilder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ function place($place) {
2020
}
2121

2222
/**
23-
* @param Priority $priority
23+
* @param $priority
24+
* either an instance of Priority, or a string in upper case.
2425
* @return ContextBuilder
2526
*/
2627
function priority($priority) {
28+
if (is_string($priority)) {
29+
$priority = new Priority($priority);
30+
}
2731
$this->priority = $priority;
2832
return $this;
2933
}

src/org/nameapi/ontology/input/entities/person/NaturalInputPersonBuilder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,14 @@ public function name(InputPersonName $personName) {
8282
}
8383

8484
/**
85-
* @param StoragePersonGender $gender
85+
* @param $gender
86+
* either an instance of StoragePersonGender, or a string in upper case like 'MALE'.
8687
* @return NaturalInputPersonBuilder
8788
*/
8889
public function gender($gender) {
90+
if (is_string($gender)) {
91+
$gender = new StoragePersonGender($gender);
92+
}
8993
$this->gender = $gender;
9094
return $this;
9195
}

tests/functional/PersonNameParserServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testParse() {
3232
->name(InputPersonName::westernBuilder()
3333
->fullname( "John Doe" )
3434
->build())
35-
->gender(new org\nameapi\ontology\input\entities\person\gender\StoragePersonGender("FEMALE"))
35+
->gender("FEMALE")
3636
->build();
3737
$parseResult = $personNameParser->parse($inputPerson);
3838

0 commit comments

Comments
 (0)