| @@ 11-135 (lines=125) @@ | ||
| 8 | * @package Oc\Country |
|
| 9 | * @author Nick Lubisch <[email protected]> |
|
| 10 | */ |
|
| 11 | class CountryEntity |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * @var string |
|
| 15 | */ |
|
| 16 | public $short; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * @var string |
|
| 20 | */ |
|
| 21 | public $name; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @var string |
|
| 25 | */ |
|
| 26 | public $de; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * @var string |
|
| 30 | */ |
|
| 31 | public $en; |
|
| 32 | ||
| 33 | /** |
|
| 34 | * @var int |
|
| 35 | */ |
|
| 36 | public $translationId; |
|
| 37 | ||
| 38 | /** |
|
| 39 | * @var bool |
|
| 40 | */ |
|
| 41 | public $listDefaultDe; |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @var bool |
|
| 45 | */ |
|
| 46 | public $listDefaultEn; |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @var string |
|
| 50 | */ |
|
| 51 | public $sortDe; |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @var string |
|
| 55 | */ |
|
| 56 | public $sortEn; |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Checks if the entity is new. |
|
| 60 | * |
|
| 61 | * @return bool |
|
| 62 | */ |
|
| 63 | public function isNew() |
|
| 64 | { |
|
| 65 | return $this->short === null; |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * Sets properties from the database. |
|
| 70 | * |
|
| 71 | * @return array |
|
| 72 | */ |
|
| 73 | public function toDatabaseArray() |
|
| 74 | { |
|
| 75 | return [ |
|
| 76 | 'short' => $this->short, |
|
| 77 | 'name' => $this->name, |
|
| 78 | 'de' => $this->de, |
|
| 79 | 'en' => $this->en, |
|
| 80 | 'trans_id' => $this->translationId, |
|
| 81 | 'list_default_de' => $this->listDefaultDe, |
|
| 82 | 'list_default_en' => $this->listDefaultEn, |
|
| 83 | 'sort_de' => $this->sortDe, |
|
| 84 | 'sort_en' => $this->sortEn |
|
| 85 | ]; |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * Prepares database array from properties. |
|
| 90 | * |
|
| 91 | * @param array $data |
|
| 92 | * |
|
| 93 | * @return self |
|
| 94 | */ |
|
| 95 | public function fromDatabaseArray(array $data) |
|
| 96 | { |
|
| 97 | $this->short = (string) $data['short']; |
|
| 98 | $this->name = (string) $data['name']; |
|
| 99 | $this->de = (string) $data['de']; |
|
| 100 | $this->en = (string) $data['en']; |
|
| 101 | $this->translationId = (int) $data['trans_id']; |
|
| 102 | $this->listDefaultDe = (bool) $data['list_default_de']; |
|
| 103 | $this->listDefaultEn = (bool) $data['list_default_en']; |
|
| 104 | $this->sortDe = (string) $data['sort_de']; |
|
| 105 | $this->sortEn = (string) $data['sort_en']; |
|
| 106 | ||
| 107 | return $this; |
|
| 108 | } |
|
| 109 | ||
| 110 | /** |
|
| 111 | * Sets all properties from array. |
|
| 112 | * |
|
| 113 | * @param array $data |
|
| 114 | */ |
|
| 115 | public function fromArray(array $data) |
|
| 116 | { |
|
| 117 | foreach ($data as $key => $value) { |
|
| 118 | if (!property_exists($this, $key)) { |
|
| 119 | continue; |
|
| 120 | } |
|
| 121 | ||
| 122 | $this->{$key} = $value; |
|
| 123 | } |
|
| 124 | } |
|
| 125 | ||
| 126 | /** |
|
| 127 | * Returns all properties as array. |
|
| 128 | * |
|
| 129 | * @return array |
|
| 130 | */ |
|
| 131 | public function toArray() |
|
| 132 | { |
|
| 133 | return get_object_vars($this); |
|
| 134 | } |
|
| 135 | } |
|
| 136 | ||
| @@ 11-135 (lines=125) @@ | ||
| 8 | * @package Oc\Language |
|
| 9 | * @author Nick Lubisch <[email protected]> |
|
| 10 | */ |
|
| 11 | class LanguageEntity |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * @var string |
|
| 15 | */ |
|
| 16 | public $short; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * @var string |
|
| 20 | */ |
|
| 21 | public $name; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @var string |
|
| 25 | */ |
|
| 26 | public $nativeName; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * @var string |
|
| 30 | */ |
|
| 31 | public $de; |
|
| 32 | ||
| 33 | /** |
|
| 34 | * @var string |
|
| 35 | */ |
|
| 36 | public $en; |
|
| 37 | ||
| 38 | /** |
|
| 39 | * @var int |
|
| 40 | */ |
|
| 41 | public $translationId; |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @var bool |
|
| 45 | */ |
|
| 46 | public $listDefaultDe; |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @var bool |
|
| 50 | */ |
|
| 51 | public $listDefaultEn; |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @var bool |
|
| 55 | */ |
|
| 56 | public $isTranslated; |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Checks if the entity is new. |
|
| 60 | * |
|
| 61 | * @return bool |
|
| 62 | */ |
|
| 63 | public function isNew() |
|
| 64 | { |
|
| 65 | return $this->short === null; |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * Sets properties from the database. |
|
| 70 | * |
|
| 71 | * @return array |
|
| 72 | */ |
|
| 73 | public function toDatabaseArray() |
|
| 74 | { |
|
| 75 | return [ |
|
| 76 | 'short' => $this->short, |
|
| 77 | 'name' => $this->name, |
|
| 78 | 'native_name' => $this->nativeName, |
|
| 79 | 'de' => $this->de, |
|
| 80 | 'en' => $this->en, |
|
| 81 | 'trans_id' => $this->translationId, |
|
| 82 | 'list_default_de' => $this->listDefaultDe, |
|
| 83 | 'list_default_en' => $this->listDefaultEn, |
|
| 84 | 'is_translated' => $this->isTranslated |
|
| 85 | ]; |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * Prepares database array from properties. |
|
| 90 | * |
|
| 91 | * @param array $data |
|
| 92 | * |
|
| 93 | * @return self |
|
| 94 | */ |
|
| 95 | public function fromDatabaseArray(array $data) |
|
| 96 | { |
|
| 97 | $this->short = (string) strtolower($data['short']); |
|
| 98 | $this->name = (string) $data['name']; |
|
| 99 | $this->nativeName = (string) $data['native_name']; |
|
| 100 | $this->de = (string) $data['de']; |
|
| 101 | $this->en = (string) $data['en']; |
|
| 102 | $this->translationId = (int) $data['trans_id']; |
|
| 103 | $this->listDefaultDe = (bool) $data['list_default_de']; |
|
| 104 | $this->listDefaultEn = (bool) $data['list_default_en']; |
|
| 105 | $this->isTranslated = (bool) $data['is_translated']; |
|
| 106 | ||
| 107 | return $this; |
|
| 108 | } |
|
| 109 | ||
| 110 | /** |
|
| 111 | * Sets all properties from array. |
|
| 112 | * |
|
| 113 | * @param array $data |
|
| 114 | */ |
|
| 115 | public function fromArray(array $data) |
|
| 116 | { |
|
| 117 | foreach ($data as $key => $value) { |
|
| 118 | if (!property_exists($this, $key)) { |
|
| 119 | continue; |
|
| 120 | } |
|
| 121 | ||
| 122 | $this->{$key} = $value; |
|
| 123 | } |
|
| 124 | } |
|
| 125 | ||
| 126 | /** |
|
| 127 | * Returns all properties as array. |
|
| 128 | * |
|
| 129 | * @return array |
|
| 130 | */ |
|
| 131 | public function toArray() |
|
| 132 | { |
|
| 133 | return get_object_vars($this); |
|
| 134 | } |
|
| 135 | } |
|
| 136 | ||