public function name($data)
{
if (is_object($data) && isset($data->type)) {
return $data->value;
}
if ($data === '*') {
return '*';
}
if (is_array($data)) {
foreach ($data as $i => $dataItem) {
$data[$i] = $this->name($dataItem);
}
return $data;
}
$cacheKey = md5($this->startQuote . $data . $this->endQuote);
if ($return = $this->cacheMethod(__FUNCTION__, $cacheKey)) {
return $return;
}
$data = trim($data);
if (preg_match('/^[\\w-]+(?:\\.[^ \\*]*)*$/', $data)) {
// string, string.string
if (strpos($data, '.') === false) {
// string
return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote . $data . $this->endQuote);
}
$items = explode('.', $data);
return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote . implode($this->endQuote . '.' . $this->startQuote, $items) . $this->endQuote);
}
if (preg_match('/^[\\w-]+\\.\\*$/', $data)) {
// string.*
return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote . str_replace('.*', $this->endQuote . '.*', $data));
}
if (preg_match('/^([\\w-]+)\\((.*)\\)$/', $data, $matches)) {
// Functions
return $this->cacheMethod(__FUNCTION__, $cacheKey, $matches[1] . '(' . $this->name($matches[2]) . ')');
}
if (preg_match('/^([\\w-]+(\\.[\\w-]+|\\(.*\\))*)\\s+' . preg_quote($this->alias) . '\\s*([\\w-]+)$/i', $data, $matches)) {
return $this->cacheMethod(__FUNCTION__, $cacheKey, preg_replace('/\\s{2,}/', ' ', $this->name($matches[1]) . ' ' . $this->alias . ' ' . $this->name($matches[3])));
}
if (preg_match('/^[\\w-_\\s]*[\\w-_]+/', $data)) {
return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote . $data . $this->endQuote);
}
return $this->cacheMethod(__FUNCTION__, $cacheKey, $data);
}