* Returns attribute values. * @param array $names list of attributes whose value needs to be returned. * Defaults to null, meaning all attributes listed in [[attributes()]] will be returned. * If it is an array, only the attributes in the array will be returned. * @param array $except list of attributes whose value should NOT be returned. * @return array attribute values (
($names = null, $except = [])
| 710 | * @return array attribute values (name => value). |
| 711 | */ |
| 712 | public function getAttributes($names = null, $except = []) |
| 713 | { |
| 714 | $values = []; |
| 715 | if ($names === null) { |
| 716 | $names = $this->attributes(); |
| 717 | } |
| 718 | foreach ($names as $name) { |
| 719 | $values[$name] = $this->$name; |
| 720 | } |
| 721 | foreach ($except as $name) { |
| 722 | unset($values[$name]); |
| 723 | } |
| 724 | |
| 725 | return $values; |
| 726 | } |
| 727 | |
| 728 | /** |
| 729 | * Sets the attribute values in a massive way. |
no test coverage detected