CommerceGuys\Zone\Matcher\ZoneMatcher::match PHP Method

match() public method

public match ( CommerceGuys\Addressing\AddressInterface $address, $scope = null )
$address CommerceGuys\Addressing\AddressInterface
    public function match(AddressInterface $address, $scope = null)
    {
        $zones = $this->matchAll($address, $scope);
        return count($zones) ? $zones[0] : null;
    }

Usage Example

 /**
  * @covers ::match
  *
  * @uses \CommerceGuys\Zone\Matcher\ZoneMatcher::__construct
  * @uses \CommerceGuys\Zone\Matcher\ZoneMatcher::matchAll
  */
 public function testMatch()
 {
     $address = $this->getMockBuilder('CommerceGuys\\Addressing\\Model\\Address')->disableOriginalConstructor()->getMock();
     $zone = $this->matcher->match($address);
     $this->assertInstanceOf('CommerceGuys\\Zone\\Model\\Zone', $zone);
     $this->assertEquals('de3', $zone->getId());
 }