Skip to content

Commit

Permalink
Remove ambiguous getCountries method
Browse files Browse the repository at this point in the history
  • Loading branch information
Propaganistas committed Sep 4, 2019
1 parent 3771d60 commit 2dc2136
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
10 changes: 0 additions & 10 deletions src/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,6 @@ public function getCountry()
return $this->country;
}

/**
* Get the countries associated with the phone number.
*
* @return array
*/
public function getCountries()
{
return $this->countries;
}

/**
* Check if the phone number is of (a) given country(ies).
*
Expand Down
30 changes: 8 additions & 22 deletions tests/PhoneNumberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,21 @@ public function it_can_construct()
}

/** @test */
public function it_can_set_temporary_countries()
public function it_can_return_the_country()
{
$object = new PhoneNumber('012345678');
$object = $object->ofCountry('BE');
$this->assertEquals(['BE'], $object->getCountries());

$object = $object->ofCountry(['NL', 'FR']);
$this->assertEquals(['BE', 'NL', 'FR'], $object->getCountries());
$object = $object->ofCountry('NL', 'FR', 'BE');
$this->assertEquals('BE', $object->getCountry());

$object = $object->ofCountry('AU', 'CH');
$this->assertEquals(['BE', 'NL', 'FR', 'AU', 'CH'], $object->getCountries());
$object = new PhoneNumber('+3212345678');
$this->assertEquals('BE', $object->getCountry());
}

/** @test */
public function it_will_filter_invalid_countries()
public function it_will_ignore_invalid_countries()
{
$object = new PhoneNumber('012345678');
$object = $object->ofCountry('BE', 'foo', 23);
$this->assertEquals(['BE'], $object->getCountries());
}

/** @test */
public function it_can_return_the_country()
{
$object = new PhoneNumber('012345678');
$object = $object->ofCountry('NL', 'FR', 'BE');
$this->assertEquals('BE', $object->getCountry());

$object = new PhoneNumber('+3212345678');
$this->assertEquals('BE', $object->getCountry());
}

Expand Down Expand Up @@ -84,11 +70,11 @@ public function it_can_make()

$object = PhoneNumber::make('012345678', 'BE');
$this->assertEquals('+3212345678', (string) $object);
$this->assertEquals(['BE'], $object->getCountries());
$this->assertEquals('BE', $object->getCountry());

$object = PhoneNumber::make('012345678', ['BE', 'NL']);
$this->assertEquals('+3212345678', (string) $object);
$this->assertEquals(['BE', 'NL'], $object->getCountries());
$this->assertEquals('BE', $object->getCountry());
}

/** @test */
Expand Down

0 comments on commit 2dc2136

Please sign in to comment.