Parse image properties.

@param array  $properties
@param string $slug

@return array
19484
protected function parseProperties(array $properties, string $slug)
    {
        switch (count($properties)) {
            case 1:
                // Square with defaults.
                return [$properties[0], $properties[0], false, false];
                break;
            case 2:
                // Custom size with defaults.
                return [$properties[0], $properties[1], false, false];
                break;
            case 3:
                // Custom size with custom crop option.
                return [$properties[0], $properties[1], $properties[2], false];
                break;
            case 4:
            default:
                // All properties with custom label.
                $label = (is_bool($properties[3]) && true === $properties[3]) ? $this->label($slug) : $properties[3];

                return [$properties[0], $properties[1], $properties[2], $label];
        }
    }
131108
private function findPackages($slugs)
    {
        $packages = [];

        foreach ($slugs as $package_slug) {
            $packageDir = $this->workingDir . '/vendor/' . $package_slug .'/';

            if (! is_dir($packageDir)) {
                continue;
            }

            $package = new Package($packageDir);
            $package->findAutoloaders();

            $config = json_decode(file_get_contents($packageDir . 'composer.json'));

            $dependencies = [];
            if (isset($config->require)) {
                $dependencies = array_keys((array)$config->require);
            }

            $package->dependencies = $this->findPackages($dependencies);
            $packages[] = $package;
        }

        return $packages;
    }
460983
public static function get(array $properties)
    {
        if (!array_key_exists('columns', $properties)) {
            throw new Exception('An index requires at least one column.');
        }

        $index = new Index();

        foreach ((array) $properties['columns'] as $column) {
            $index->addColumn($column);
        }

        if (array_key_exists('name', $properties) && !empty($properties['name'])) {
            $index->setName($properties['name']);
        }

        if (array_key_exists('type', $properties) && !empty($properties['type'])) {
            $index->setType($properties['type']);
        }

        return $index;
    }
1248601
public function template( string $slug, array $files = []) {
		$files = $files ?: (array) "{$slug}.php";
		
		return apply_filters("{$slug}_template", $this->locate( $files ) );
	}
600585
public function properties (array $properties = array())
    {
        $res = '';
        
        if (!empty($properties)) {
            foreach ($properties as $key => $property) {
                $res .= ' ' . $key . '="' . $property . '"';
            }
        }

        return $res;
    }
695957
protected function get_plugin_info( $slug ) {

		$args = (object) [ 'slug' => $slug ];

		$request = [
			'action'  => 'plugin_information',
			'timeout' => 15,
			'request' => serialize( $args ),
		];

		$url = Plugin::WP_Plugin_Info()->getOption( 'url', 'wp-api' );

		$resp = wp_remote_post( $url, [ 'body' => $request ] );

		$resp = isset( $resp['body'] ) ? unserialize( $resp['body'] ) : [];

		unset( $resp->sections, $resp->versions, $resp->screenshots );

		return (array) $resp;
	}
836222
public function saveImageSet($slug, $postValues)
    {
        $imageSetObject = ImageSetFactory::createImageSetFromPostValues($postValues);

        $imageSet = $this->repository->imageSet;
        foreach ($imageSet as $key => $set) {
            if ($set->slug == $slug) {
                $imageSet[$key] = $imageSetObject;
            }
        }
        $this->repository->imageSet = $imageSet;
        $this->save();
    }
56648
protected function attributesFromProperties(array $properties): array
    {
        // First, we'll only keep the entities that are part of the Entity's
        // attributes
        $managedProperties = $this->getManagedProperties();

        $properties = array_only($properties, $managedProperties);

        // If the entity does not uses the attributes array to store
        // part of its attributes, we'll directly return the properties
        if (!$this->entityMap->usesAttributesArray()) {
            return $properties;
        }

        $arrayName = $this->entityMap->getAttributesArrayName();

        if (!array_key_exists($arrayName, $properties)) {
            throw new MappingException("Property $arrayName not set on object of type ".$this->getEntityClass());
        }

        if (!is_array($properties[$arrayName])) {
            throw new MappingException("Property $arrayName should be an array.");
        }

        $attributes = $properties[$arrayName];

        unset($properties[$arrayName]);

        return $properties + $attributes;
    }
1112209
public function load($properties)
    {
        $keys = $this->_entity->getIdentifyingData();

        $this->_entity->getRepository()->getCommandChain()->disable();

        $query = $this->_entity->getRepository()->getQuery()
                    ->columns($properties)
                    ->where($keys);

        $data = $this->_entity->getRepository()->fetch($query, AnDomain::FETCH_ROW);

        if (!empty($data)) {
            $this->_row = array_merge($this->_row, (array) $data);

            foreach ($properties as $property) {
                unset($this->_materialized[$property]);
            }
        }

        $this->_entity->getRepository()->getCommandChain()->enable();

        return !empty($data);
    }
11555
protected function filterNestedContext(array $properties = [])
    {
        $func = function($value, $key) {
            return ($value && $key !== '@context');
        };

        if (!defined('ARRAY_FILTER_USE_BOTH')) {
            $return = [];
            foreach ($properties as $k => $v) {
                if (call_user_func($func, $v, $k)) {
                    $return[$k] = $v;
                }
            }

            return $return;
        }

        return array_filter($properties, $func, ARRAY_FILTER_USE_BOTH);
    }
389213
public function buildPropertiesString(array $properties)
    {
        $chunks = array();

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

        return implode(' ', $chunks);
    }
407665
final public static function format_properties($properties) {
        foreach ($properties as $property => $definition) {
            // Ensures that null is set to its default.
            if (!isset($definition['null'])) {
                $properties[$property]['null'] = NULL_NOT_ALLOWED;
            }
            if (!isset($definition['description'])) {
                $properties[$property]['description'] = $property;
            }

            // If an array is provided, it may be a nested array that is unformatted so rinse and repeat.
            if (is_array($definition['type'])) {
                $properties[$property]['type'] = static::format_properties($definition['type']);
            }
        }
        return $properties;
    }
1107401
private function parseFields(array $fields)
    {
        $propertyStub = $this->generateProperty();
        $setterStub   = $this->generateSetter();
        $getterStub   = $this->generateGetter();
        foreach ($fields as $fieldInfo) {
            $this->parseProperty($propertyStub, $fieldInfo);
            $this->parseSetter($setterStub, $fieldInfo);
            $this->parseGetter($getterStub, $fieldInfo);
        }
    }
184349
private static function readProperty(int $key, array $properties)
    {
        assert(array_key_exists($key, $properties));

        return $properties[$key];
    }
682220
public function sliceProperties(array $properties)
    {
        $actions = $this->internalDataListActions;
        $actions[] = ['sliceProperties', $properties];
        $data = $this->internalDataListUpdateData($this->internalDataListData, $actions);
        $className = get_class($this);
        $list = new $className();
        $class = $this->internalDataListClasses['IvoPetkov\DataListObject'];
        $tempObject = new $class();
        foreach ($data as $index => $object) {
            $object = $this->internalDataListUpdateValueIfNeeded($data, $index);
            $newObject = clone($tempObject);
            foreach ($properties as $property) {
                $newObject[$property] = isset($object->$property) ? $object->$property : null;
            }
            $list->push($newObject);
        }
        return $list;
    }
114372
protected static function setIconAttribute(array $properties)
    {
        $icon = array_get($properties, 'attributes.icon');
        if (!is_null($icon)) {
            $properties['icon'] = $icon;

            array_forget($properties, 'attributes.icon');

            return $properties;
        }

        return $properties;
    }
82733
public function &__get($property)
    {
        $get[ $property ] = false;

        if (services()->has($property)) {
            $get[ $property ] = services()->get($property);
        } elseif (array_key_exists($property, $this->validSubModels)) {
            $get[ $property ] = $this->loadSubModel($property);
        } elseif (o2system()->__isset($property)) {
            $get[ $property ] = o2system()->__get($property);
        }

        return $get[ $property ];
    }