| @@ 68-79 (lines=12) @@ | ||
| 65 | protected function hydrate(array $data) |
|
| 66 | { |
|
| 67 | $this->data = []; |
|
| 68 | foreach ($data as $key => $value) |
|
| 69 | { |
|
| 70 | $setter = sprintf('set%s', ucfirst(Inflector::camelize($key))); |
|
| 71 | if (method_exists($this, $setter)) |
|
| 72 | { |
|
| 73 | $this->$setter($value); |
|
| 74 | } |
|
| 75 | else |
|
| 76 | { |
|
| 77 | $this->data[$key] = $value; |
|
| 78 | } |
|
| 79 | } |
|
| 80 | ||
| 81 | $this->postHydrate($data); |
|
| 82 | } |
|
| @@ 112-116 (lines=5) @@ | ||
| 109 | } |
|
| 110 | else |
|
| 111 | { |
|
| 112 | foreach ($fieldNames as $fieldName) |
|
| 113 | { |
|
| 114 | $getter = sprintf('get%s', ucfirst(Inflector::camelize($fieldName))); |
|
| 115 | $data[$fieldName] = method_exists($this, $getter) ? $this->$getter() : $this->data[$fieldName]; |
|
| 116 | } |
|
| 117 | } |
|
| 118 | ||
| 119 | $this->postDehydrate($data); |
|