Generate option enum values.

@param array $attributes
@param array $columnData

@return array Attributes
768448
protected function getOptionEnumValue(array $attributes, array $columnData): array
    {
        $match = null;
        $pattern = '/enum\((.*)\)/';
        if (preg_match($pattern, $columnData['COLUMN_TYPE'], $match) === 1) {
            $values = str_getcsv($match[1], ',', "'", '\\');
            $attributes['values'] = $values;
        }

        return $attributes;
    }
678270
protected function getPhinxColumnOptionsNumeric(array $attributes, array $columnData): array
    {
        $dataType = $columnData['DATA_TYPE'];

        $intDefaultLimits = [
            'int' => '11',
            'bigint' => '20',
        ];

        // For integer and biginteger columns
        if ($dataType === 'int' || $dataType === 'bigint') {
            $match = null;
            if (preg_match('/\((\d+)\)/', $columnData['COLUMN_TYPE'], $match) === 1) {
                if ($match[1] !== $intDefaultLimits[$dataType]) {
                    $attributes['limit'] = $match[1];
                }
            }

            // signed enable or disable the unsigned option (only applies to MySQL)
            $match = null;
            $pattern = '/\(\d+\) unsigned$/';
            if (preg_match($pattern, $columnData['COLUMN_TYPE'], $match) === 1) {
                $attributes['signed'] = false;
            }

            // identity enable or disable automatic incrementing
            if ($columnData['EXTRA'] == 'auto_increment') {
                $attributes['identity'] = 'enable';
            }
        }

        // For decimal columns
        if ($dataType === 'decimal') {
            // Set decimal accuracy
            if (!empty($columnData['NUMERIC_PRECISION'])) {
                $attributes['precision'] = $columnData['NUMERIC_PRECISION'];
            }
            if (!empty($columnData['NUMERIC_SCALE'])) {
                $attributes['scale'] = $columnData['NUMERIC_SCALE'];
            }
        }

        return $attributes;
    }
951756
public function getBy($attribute, $value, $columns = array('*'))
    {
        return $this->model->where($attribute, '=', $value)->get($columns);
    }
183876
protected function convertValueForColumn($value, ColumnMap $colMap)
    {
        if ($colMap->getType() == 'OBJECT' && is_object($value)) {
            if (is_array($value)) {
                $value = array_map('serialize', $value);
            } else {
                $value = serialize($value);
            }
        } elseif ($colMap->getType() == 'ARRAY' && is_array($value)) {
            $value = '| ' . implode(' | ', $value) . ' |';
        } elseif ($colMap->getType() == 'ENUM') {
            if (is_array($value)) {
                $value = array_map(array($colMap, 'getValueSetKey'), $value);
            } else {
                $value = $colMap->getValueSetKey($value);
            }
        }

        return $value;
    }
333680
public function getEnumValues($tableName, $columnName) {

		// check whether column exists

		if(!$this->columnExists($tableName, $columnName)) {
			throw new \PDOException(sprintf("Unknown column '%s' in table '%s'.", $columnName, $tableName));
		}
		
		// wrong data type
		
		$dataType = $this->tableStructureCache[$tableName][$columnName]['dataType']; 
		
		if(!($dataType === 'enum' || $dataType === 'set')) {
			throw new \PDOException(sprintf("Column '%s' in table '%s' is not of type ENUM or SET.", $columnName, $tableName));
		}
		
		// extract enum values the first time

		if(!isset($this->tableStructureCache[$tableName][$columnName]['enumValues'])) {
			preg_match_all(
				"~'(.*?)'~i",
				$this->tableStructureCache[$tableName][$columnName]['columnType'],
				$matches
			);
			
			$this->tableStructureCache[$tableName][$columnName]['enumValues'] = $matches[1];
		}
		
		return $this->tableStructureCache[$tableName][$columnName]['enumValues'];
		
	}
687738
public function findManyBy($attribute, array $values = [], $columns = [])
    {
        $query = $this->select($columns);

        foreach ($values as $value) {
            $query->orWhere([$attribute => $value]);
        }

        return $query->get();
    }
681097
function formatAttrs(attributes, opts, keyOnlyAttribs = []) {
  if (!attributes) return;

  var output = '',
    value;

  // Loop through the attributes
  for (var key in attributes) {
    value = attributes[key];
    if (output) {
      output += ' ';
    }

    if (!value && booleanAttributes[key] || isExpr(key) || isKeyOnlyAttr(key, keyOnlyAttribs)) {
      output += key;
    } else {
      output += key + `=${isExpr(value) ? '' : '"'}` + (opts.decodeEntities ? entities.encodeXML(value) : value) + (isExpr(value) ? '' : '"');
    }
  }

  return output;
}
1321286
protected function addColumns(SelectStatement $selectStmt, $tableName, $attributes=null) {
    // columns
    $attributeDescs = $this->getAttributes();
    $columns = [];
    foreach($attributeDescs as $curAttributeDesc) {
      $name = $curAttributeDesc->getName();
      if (($attributes == null || in_array($name, $attributes)) && $curAttributeDesc instanceof RDBAttributeDescription) {
        $columns[$curAttributeDesc->getName()] = $curAttributeDesc->getColumn();
      }
    }
    $selectStmt->columns($columns, true);

    // references
    $selectStmt = $this->addReferences($selectStmt, $tableName);
    return $selectStmt;
  }
1254133
protected function getPhinxColumnOptionsAfter($attributes, $columnData, $columns)
    {
        $columnName = $columnData['COLUMN_NAME'];
        $after = null;
        foreach (array_keys($columns) as $column) {
            if ($column === $columnName) {
                break;
            }
            $after = $column;
        }
        if (!empty($after)) {
            $attributes[] = sprintf('\'after\' => \'%s\'', $after);
        }

        return $attributes;
    }
272076
def _write_enums(self, entity_name, attributes):
        
        
        self.enum_attrs_for_locale[entity_name] = attributes;

        for attribute in attributes:
            enum_name = "%s%sEnum" % (entity_name, attribute.name[0].upper() + attribute.name[1:])
            self.enum_list.append(enum_name)
            filename = "%s%s.js" % (self._class_prefix, enum_name)
            self.write(destination = self.enum_directory,
                        filename=filename,
                        template_name="enum.js.tpl",
                        class_prefix = self._class_prefix,
                        enum_name = enum_name,
                        allowed_choices = set(attribute.allowed_choices))
944687
protected function generateTH($thData, $attributes = array())
    {
        $thData = strtoupper(str_replace("_", " ", $thData->getName()));
        return $this->generateElement('th', $attributes, $thData, true);
    }
521928
protected function getConvertedValues($values, $attribute, $direction, AttributeConverterInterface $aggregate = null)
    {
        $values = is_array($values) ? $values : [$values];
        $converter = $this->getConverterWithOptions($this->schema->getConverter($attribute), $attribute);

        if (!$aggregate && $converter->getShouldAggregateValues() && $direction == 'toLdap') {
            $values = $this->convertAggregateValues($attribute, $values);
        } else {
            $values = $this->doConvertValues($attribute, $values, $direction, $aggregate);
        }

        return $values;
    }
387268
public static function attributesBeautifier($arrayData = [],$arrayAttributes = []){
        $beautified = [];
        array_walk($arrayData, function(&$val) use (&$beautified,$arrayAttributes){$beautified[md5($val[0])] = array_combine($arrayAttributes,$val);});
        return $beautified;
    }
30079
protected function doConvertValues($attribute, array $values, $direction, AttributeConverterInterface $aggregate = null)
    {
        $converter = $aggregate ?: $this->getConverterWithOptions($this->schema->getConverter($attribute), $attribute);
        $converter->setAttribute($attribute);

        if ($converter->isMultiValuedConverter()) {
            $values = $converter->$direction($values);
        } else {
            foreach ($values as $index => $value) {
                $values[$index] = $converter->$direction($value);
            }
        }
        if ($converter instanceof OperationGeneratorInterface && $converter->getRemoveOriginalValue() && !in_array($attribute, $this->remove)) {
            $this->remove[] = $attribute;
        }

        return $values;
    }
26168
protected static function attribute($attributes = [])
	{
		$text = '';
		foreach ($attributes as $option => $value) {
			$text = ' ' . $option . '="' . $value . '"';
		}
		return $text;
	}
1044630
protected function getPhinxColumnOptions($phinxType, $columnData, $columns)
    {
        $attributes = [];

        $attributes = $this->getPhinxColumnOptionsNull($attributes, $columnData);

        // default value
        $attributes = $this->getPhinxColumnOptionsDefault($attributes, $columnData);

        // For timestamp columns:
        $attributes = $this->getPhinxColumnOptionsTimestamp($attributes, $columnData);

        // limit / length
        $attributes = $this->getPhinxColumnOptionsLimit($attributes, $columnData);

        // numeric attributes
        $attributes = $this->getPhinxColumnOptionsNumeric($attributes, $columnData);

        // enum values
        if ($phinxType === 'enum') {
            $attributes = $this->getOptionEnumValue($attributes, $columnData);
        }

        // Collation
        $attributes = $this->getPhinxColumnCollation($phinxType, $attributes, $columnData);

        // Encoding
        $attributes = $this->getPhinxColumnEncoding($phinxType, $attributes, $columnData);

        // Comment
        $attributes = $this->getPhinxColumnOptionsComment($attributes, $columnData);

        // after: specify the column that a new column should be placed after
        $attributes = $this->getPhinxColumnOptionsAfter($attributes, $columnData, $columns);

        // @todo
        // update set an action to be triggered when the row is updated (use with CURRENT_TIMESTAMP)
        //
        // For foreign key definitions:
        // update set an action to be triggered when the row is updated
        // delete set an action to be triggered when the row is deleted

        $result = '[' . implode(', ', $attributes) . ']';

        return $result;
    }
93707
public function generateProperties ()
	{
		
		$attributes	= $this->getAttributes ();
		
		$properties	= 'Class Properties:' . "\n";
		
		foreach ($attributes as $name => $attribute)
		{
			
			$properties	.= '@property ';
			
			switch ($attribute['type'])
			{
				
				case 'self::TYPE_INT':
					$properties	.= 'integer'; break;
				
				case 'self::TYPE_STRING':
					$properties	.= 'string'; break;
				
				case 'self::TYPE_BOOL':
					$properties	.= 'boolean'; break;
				
				case 'self::TYPE_DATE':
					$properties	.= 'date'; break;
				
				case 'self::TYPE_DATETIME':
					$properties	.= 'datetime'; break;
				
				case 'self::TYPE_DECIMAL':
					$properties	.= 'float'; break;
				
				case 'self::TYPE_ENUM':
					$properties	.= 'enum'; break;
				
				case 'self::TYPE_BINARY':
					$properties	.= 'binary'; break;
				
			}
			
			$properties	.= ' $' . $name . "\n";
			
		}
		
		// Remove last ,

		if (substr ($properties, -1) == "\n")
		{
			$properties	= substr ($properties, 0, -1);
		}
		
		return $properties;
		
	}