key = $options[self::KEY_SOURCE]; } /** * Get value of $data using $key * * @param array $data A CSV line * @return string * @throws MetadataReaderNotFoundException */ public function getValue(array $data) { $key = strtolower($this->key); if ($this->hasValue($data, $key)) { return $data[$key]; } throw new MetadataReaderNotFoundException(__CLASS__ . ' cannot found value associated to key "' . $this->key . '".'); } /** * Check if $key of $data array exists * * @param array $data * @param $key * @return bool */ protected function hasValue(array $data, $key) { if (! is_string($key)) { return false; } return isset($data[$key]); } /** * Configuration serialization * * @return array */ public function __toPhpCode() { $options = ['key' => $this->key]; return empty($options) ? '' : \common_Utils::toHumanReadablePhpString($options); } }