CommerceGuys\Addressing\AddressFormat\AddressFormatRepository::getAll PHP Method

getAll() public method

public getAll ( )
    public function getAll()
    {
        $definitions = $this->getDefinitions();
        $addressFormats = [];
        foreach ($definitions as $countryCode => $definition) {
            $definition = $this->processDefinition($countryCode, $definition);
            $addressFormats[$countryCode] = new AddressFormat($definition);
        }
        return $addressFormats;
    }

Usage Example

 /**
  * @covers ::getAll
  * @covers ::processDefinition
  * @covers ::getGenericDefinition
  * @covers ::getDefinitions
  */
 public function testGetAll()
 {
     $addressFormatRepository = new AddressFormatRepository();
     $addressFormats = $addressFormatRepository->getAll();
     $this->assertArrayHasKey('ES', $addressFormats);
     $this->assertArrayHasKey('RS', $addressFormats);
     $this->assertEquals('ES', $addressFormats['ES']->getCountryCode());
     $this->assertEquals(LocalityType::CITY, $addressFormats['ES']->getLocalityType());
     $this->assertEquals('RS', $addressFormats['RS']->getCountryCode());
     $this->assertEquals(LocalityType::CITY, $addressFormats['RS']->getLocalityType());
 }