Skip to content

Instantly share code, notes, and snippets.

@wkocmann
Created January 9, 2014 10:53
Show Gist options
  • Save wkocmann/4f6843e15db5401cdefc to your computer and use it in GitHub Desktop.
Save wkocmann/4f6843e15db5401cdefc to your computer and use it in GitHub Desktop.
multilingual value object and repository
<?php
class Country
{
public $ISO;
public $Name;
public function __construct($ISOCode, $Name)
{
$this->ISO = $ISOCode;
$this->Name = $Name
}
}
class CountryRepository
{
private $countries = array(
array('ISO' => 'AT', 'Name' => 'Austria'),
array('ISO' => 'DE', 'Name' => 'Germany'),
array('ISO' => 'BE', 'Name' => 'Belgium')
);
public function findAll()
{
$ret = array();
for ($i = 0, $lC = count($this->countries); $i < $lC; $i++) {
$ret[] = New Country($this->countries['ISO'], $this->countries['Name']);
}
return $ret;
}
}
class EN_CountryRepository extends CountryRepository {}
class DE_CountryRepository extends CountryRepository
{
private $countries = array(
array('ISO' => 'AT', 'Name' => 'Österreich'),
array('ISO' => 'DE', 'Name' => 'Deutschland'),
array('ISO' => 'BE', 'Name' => 'Belgien')
);
}
class NL_CountryRepository extends CountryRepository
{
private $countries = array(
array('ISO' => 'AT', 'Name' => 'Oostenrijk'),
array('ISO' => 'DE', 'Name' => 'Duitsland'),
array('ISO' => 'BE', 'Name' => 'België')
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment