Returns the format properties.

@param array $properties

@return array
184144
protected function ensureFormatProperties(array $properties)
	{
		// defaults keys for transforming
		$properties += [
			'bit_rate'    => 0,
			'duration'    => 0.0,
			'format_name' => '',
			'tags'        => [],
			'codecs'      => []
		];
		
		if ( ! empty($this->options[ServiceFactoryInterface::OPTION_TEST_CODECS]))
		{
			$properties['codecs'] = $this->getAvailableCodecs();
		}
		
		$properties['metadata'] = (array) $properties['tags'];
		$properties['format'] = $properties['format_name'];
		$properties['bitrate'] = $properties['bit_rate'];
		
		unset($properties['tags'], $properties['bit_rate']);
		
		return $properties;
	}
411674
final private function prepareData($properties) {
	
		// trigger before preparing data
		$this->beforePrepareData();
		
		// properly cast a property of this object and return it
		$cast = function($prop) {
			
			$field = static::getMappedField($prop);

			switch ($this->getPropertyType($prop)) {
				
				// integer or bool will cast to integer
				case 'int':
				case 'bool':
					if (is_null($this->$prop) and static::isNullable($field)) {
						$ret = NULL;
					} else {
						$ret = (int)$this->$prop;
					}
					break;
				
				// should be DateTime, maybe null
				case 'DateTime':
					if (is_a($this->$prop, 'DateTime')) {
						$dt = clone($this->$prop);
						$dt->setTimezone(new \DateTimeZone(BASE_TIMEZONE));
						$ret = $dt->format('Y-m-d H:i:s');
					} else if (static::isNullable($field)) {
						$ret = NULL;
					} else {
						$field = static::getColumnType($field);
						$ret = 'date' == $field->type ? '0000-00-00' :'0000-00-00 00:00:00';
					}
					break;
						
				// join array strings in CSV format 
				case 'csv':
					$ret = implode(',', array_filter((array)$this->$prop));
					break;
					
				case 'float':
					if (is_null($this->$prop) and static::isNullable($field)) {
						$ret = NULL;
					} else {
						$curr = setlocale(LC_NUMERIC, 0);
						setlocale(LC_NUMERIC, 'en_US');
						$ret = (string)$this->$prop;
						setlocale(LC_NUMERIC, $curr);
					}
					break;

				// assign with no convertion
				default:
					if ((is_null($this->$prop) or (''==$this->$prop and !static::isEmptiable($field)))
							and static::isNullable($field)) {
						$ret = NULL;
					} else {
						$ret = $this->$prop;
					}
					break;
					
			}
			
			return $ret;
			
		};
		
		// force to array
		$properties	= (array)$properties;

		$class = get_called_class();
		$binds = $class::getBinds();
		
		// create the return object
		$dbObj = new \stdClass();
		
		foreach ($properties as $prop) {
			if (array_key_exists($prop, $binds)) {
				$dbObj->{$binds[$prop]} = $cast($prop);
			}
		}
		
		// trigger after prepared data
		$this->afterPrepareData($dbObj);
			
		return $dbObj;
	
	}
450241
protected function listProperties(array $properties)
    {
        $headings = [];
        $values = [];
        foreach ($properties as $key => $value) {
            $headings[] = new AdaptiveTableCell($key, ['wrap' => false]);
            $values[] = $this->formatter->format($value, $key);
        }
        /** @var \Platformsh\Cli\Service\Table $table */
        $table = $this->getService('table');
        $table->renderSimple($values, $headings);

        return 0;
    }
12941
protected function buildContext(array $properties)
    {
        $items = [];

        foreach ($properties as $key => $value) {
            $items[] = [
                    'Key' => $this->sanitizeString($key),
                    'Value' => $this->sanitizeString($value),
            ];
        }

        if (!$items) {
            return [];
        }

        return ['Entry' => $items];
    }
200657
private function getPropertySettings($property)
    {
        $data = [];
        $settings = [
            'minimum' => 'min',
            'maximum' => 'max',
        ];
        foreach ($settings as $setting => $name) {
            if (isset($property[$setting])) {
                $data[] = $name.':'.$property[$setting];
            }
        }

        return implode(' | ', $data);
    }
298513
public function apply(array $properties)
    {
        foreach ($properties as $key => $value) {
            if (true === $this->isHasOne($key)) {
                if (empty($value)) {
                    $this->clear($key);
                    continue;
                }
                $value = $this->store->loadProxyModel($value['type'], $value['id']);
                $this->set($key, $value);
                continue;
            }

        }

        foreach ($this->getMetadata()->getRelationships() as $key => $relMeta) {
            if (true === $relMeta->isOne()) {
                continue;
            }
            if (!isset($properties[$key]) || true === $relMeta->isInverse) {
                continue;
            }
            $this->clear($key);
            $collection = $this->store->createCollection($relMeta, $properties[$key]);
            foreach ($collection->allWithoutLoad() as $value) {
                $this->push($key, $value);
            }
        }
        return parent::apply($properties);
    }
389213
public function buildPropertiesString(array $properties)
    {
        $chunks = array();

        foreach ($properties as $property) {
            $chunks[] = $property->toString();
        }

        return implode(' ', $chunks);
    }
848382
protected function getParametersList(array $values)
    {
        $parameters = [];

        foreach ($values as $name => $value) {
            $parameters[$name] = sprintf(
                "$*::%s",
                $this->getStructure()->getTypeFor($name)
            );
        }

        return $parameters;
    }
392458
public function Field($properties = array())
    {
        // Build inner content
        $fieldContent = '';
        foreach ($this->getChildren() as $field) {
            /** @var FormField $field */
            $field->setDisabled($this->isDisabled());
            $field->setReadonly($this->isReadonly());

            if (count($this->attributes)) {
                foreach ($this->attributes as $name => $value) {
                    $field->setAttribute($name, $value);
                }
            }

            $fieldContent .= $field->FieldHolder();
        }

        if (!$this->showOnClick) {
            return $fieldContent;
        }

        if ($this->getShowOnClickTitle()) {
            $title = $this->getShowOnClickTitle();
        } else {
            $title = _t(
                __CLASS__ . '.SHOWONCLICKTITLE',
                'Change Password',
                'Label of the link which triggers display of the "change password" formfields'
            );
        }

        // Check if the field should be visible up front
        $visible = $this->hiddenField->Value();
        $classes = $visible
            ? 'showOnClickContainer'
            : 'showOnClickContainer d-none';

        // Build display holder
        $container = HTML::createTag('div', ['class' => $classes], $fieldContent);
        $actionLink = HTML::createTag('a', ['href' => '#'], $title);
        return HTML::createTag(
            'div',
            ['class' => 'showOnClick'],
            $actionLink . "\n" . $container
        );
    }
418929
protected function generateStyle(array $properties)
	{
		ksort($properties);

		$style = '';
		foreach ($properties as $name => $value)
		{
			$style .= $name . ':' . $value . ';';
		}

		return trim($style, ';');
	}
381582
public function data(array $properties = null)
    {
        $data = [];
        $properties = $this->properties($properties);
        foreach ($properties as $propertyIdent => $property) {
            // Ensure objects are properly encoded.
            $val = $this->propertyValue($propertyIdent);
            $val = $this->serializedValue($val);
            $data[$propertyIdent] = $val;
        }

        return $data;
    }
759972
protected function resolveStreamProperties(array $properties)
	{
		// defaults keys for transforming
		$properties += [
			'tags'            => [],
			'sample_rate'     => 0,
			'codec_name'      => null,
			'codec_long_name' => '',
			'type'            => $properties['codec_type'],
			'frequency'       => 0,
			'channels'        => 1
		];
		
		$properties['metadata'] = (array) $properties['tags'];
		$properties['frequency'] = (int) $properties['sample_rate'];
		$properties['codec'] = new Codec($properties['codec_name'], $properties['codec_long_name']);
		$properties['frame_rate'] = isset($properties['r_frame_rate']) ? $properties['r_frame_rate'] : 0.0;
		
		if (strpos($properties['frame_rate'], '/') > 0)
		{
			list($val1, $val2) = explode('/', $properties['frame_rate']);
			
			if ($val1 > 0 && $val2 > 0)
			{
				$properties['frame_rate'] = (float) $val1 / (float) $val2;
			}
		}
		
		return $properties;
	}
850925
public static function serialize(array $values): array
    {
        $serializedData = [];

        foreach ($values as $property => $value) {
            if (is_array($value)) {
                $value = self::serialize($value);
            }

            if ($value instanceof Serializable) {
                $value = $value->serialize();
            }

            $serializedData[$property] = $value;
        }

        return $serializedData;
    }
213237
protected static function getRelations(array $properties)
    {
        $relations = [];

        foreach ($properties as $property) {
            if (!is_null($relation = ForeignRelationship::get($property))) {
                $relations[] = $relation;
            }
        }

        return $relations;
    }
1023257
protected function getObjectProperties(array $objects): array
    {
        $objectProperties = [];
        /** @var ITypedObject[] $objects */
        foreach ($objects as $key => $object) {
            $objectProperties[$key] = $object->toArray();
        }

        return $objectProperties;
    }
506533
public function Field($properties = array())
    {
        $properties = array_merge($properties, array(
            'Options' => $this->getOptions(),
        ));

        return FormField::Field($properties);
    }
1345004
public function getProperty($property)
    {
        $values = array();
        foreach ($this->columns as $key => $col) {
            if (isset($col[$property])) {
                $values[$key] = $col[$property];
            } else {
                $values[$key] = null;
            }
        }
    }