Creates an embedded asset model from an array of property/value pairs.
Returns the model unless the array included any properties that aren't defined on the model.

@param array $array
@return EmbeddedAsset|null
160469
private function createEmbeddedAsset(array $array)
	{
		$embeddedAsset = new EmbeddedAsset();

		$isLegacy = isset($array['__embeddedasset__']);
		if ($isLegacy)
		{
			$array = $this->_convertFromLegacy($array);
		}

		foreach ($array as $key => $value)
		{
			if (!$embeddedAsset->hasProperty($key))
			{
				return null;
			}

			switch ($key)
			{
				case 'code':
				{
					$code = $value instanceof Twig_Markup ? (string)$value :
						is_string($value) ? $value : '';

					$embeddedAsset->$key = empty($code) ? null : Template::raw($code);
				}
				break;
				default:
				{
					$embeddedAsset->$key = $value;
				}
			}
		}

		// Attempts to extract missing dimensional properties from the embed code
		$dimensions = $this->_getDimensions($embeddedAsset);
		$embeddedAsset->width = $dimensions[0];
		$embeddedAsset->height = $dimensions[1];

		// Sets aspect ratio is missing
		if (!$embeddedAsset->aspectRatio && $embeddedAsset->width && $embeddedAsset->height)
		{
			$embeddedAsset->aspectRatio = $embeddedAsset->height / $embeddedAsset->width * 100;
		}

		return $embeddedAsset->validate() ? $embeddedAsset : null;
	}
746906
public function fromArray($array) {
		if (is_array($array) && sizeof($array)>0) {
			foreach ( $array as $value ) {
				if (is_array($value)) {
					$this->addImage($value ["src"], @$value ["alt"], @$value ["caption"], @$value ["description"]);
				} else {
					$this->addImage($value);
				}
			}
		}
		return $this;
	}
1248322
protected function createModelFromArray(array $array)
    {
        $account = new SEPAAccount();
        $account->setIban($array[1]);
        $account->setBic($array[2]);
        $account->setAccountNumber($array[3]);
        $account->setSubAccount($array[4]);
        $account->setBlz($array[6]);

        return $account;
    }
389028
public static function createFromArray(array $array)
    {
        $sortBy = self::create();
        $sortBy->sortsBy = array_map(function (array $element) {
            if (
                self::RANDOM !== $element &&
                self::SCORE !== $element
            ) {
                $element['type'] = $element['type'] ?? SortBy::TYPE_FIELD;
            }

            if (isset($element['filter'])) {
                $element['filter'] = Filter::createFromArray($element['filter']);
            }

            if (
                isset($element['coordinate']) &&
                is_array($element['coordinate'])
            ) {
                $element['coordinate'] = Coordinate::createFromArray($element['coordinate']);
            }

            return $element;
        }, $array);

        return $sortBy;
    }
796388
protected function createFromArray($array)
    {
        $this->id = $array['id'];
        $this->modelType = $array['modelType'];
        $this->modelId = $array['modelId'];
        $this->name = $array['name'];
        $this->price = $array['price'];
        $this->image = $array['image'];
        $this->quantity = $array['quantity'];

        return $this;
    }
743164
private function buildDefinition(array $array)
    {
        $definition = null;
        if (isset($array['parent'])) {
            $definition = new DefinitionDecorator($array['parent']);
        } else {
            $definition = new Definition();
        }

        if (isset($array['synthetic'])) {
            $definition->setSynthetic($array['synthetic']);
        }

        $this->setDefinitionClass($definition, $array);
        $this->setDefinitionArguments($definition, $array);
        $this->setDefinitionFactory($definition, $array);
        $this->setDefinitionTags($definition, $array);
        $this->setDefinitionMethodCalls($definition, $array);
        $this->setDefinitionProperties($definition, $array);
        $this->setDefinitionConfigurator($definition, $array);

        return $definition;
    }
749329
public function arrayToObject(array $array): \stdClass
    {
        $objResult = new \stdClass();

        foreach ($array as $varKey => $varValue) {
            $objResult->{$varKey} = $varValue;
        }

        return $objResult;
    }
406952
public static function createFromAttributeArray(array $array)
	{
		$input = array_change_key_case($array, CASE_LOWER);

		$response = new Response();

		foreach (Response::$attributeMapping as $attribute => $localVariable) {
			$loweredAttribute = strtolower($attribute);

			if (array_key_exists($loweredAttribute, $input)) {
				$response->{$localVariable} = $input[$loweredAttribute];
			}
		}

		return $response;
	}
897823
public static function makeHashFromArray($array)
        {
            $hash = null;

            if (static::is($array) && count($array) > 1) {
                for ($i = 0; $i <= count($array); $i+= 2) {
                    if (isset($array[$i])) {
                        $key = $array[$i];
                        $value = $array[$i + 1];

                        if (!empty($key) && !empty($value)) {
                           $hash[$key] = $value;
                        }
                    }
                }
            }

            if (true === static::is($hash)) {
                return $hash;
            }
        }
253766
private function serializeArrayOrTable(array $array)
    {
        $assoc = false;
        $index = 0;
        $values = [];

        foreach ($array as $key => $value) {
            // We already know the array is associative, serialize both the key
            // and the value ...
            if ($assoc) {
                $values[] = $this->serializeShortString($key)
                    . $this->serializeField($value);

                // Otherwise, if the key matches the index counter it is sequential,
                // only serialize the value ...
            } elseif ($key === $index++) {
                $values[] = $this->serializeField($value);

                // Otherwise, we've just discovered the array is NOT sequential,
                // Go back through the existing values and add the keys ...
            } else {
                foreach ($values as $k => $v) {
                    $values[$k] = $this->serializeShortString($k) . $v;
                }

                $values[] = $this->serializeShortString($key)
                    . $this->serializeField($value);

                $assoc = true;
            }
        }

        return ($assoc ? 'F' : 'A') . $this->serializeByteArray(
                implode('', $values)
            );
    }
948047
protected function serializeArray(array $array) {
        $data = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $data[$key] = $this->serializeArray($value);
            } else {
                $data[$key] = $this->serializeItem($value);
            }
        }

        return $data;
    }
88836
public static function arrayClone(array $array)
    {
        return array_map(function ($element) {
                return ((is_array($element))
                    ? call_user_func(__FUNCTION__, $element)
                    : ((is_object($element))
                        ? clone $element
                        : $element
                    )
                );
        }, $array);
    }
1189624
public static function removeNull(array $array)
    {
        $result = [];
        foreach ($array as $key => $value) {
            if (is_null($value)) {
                continue;
            }
            $result[$key] = $value;
        }
        return $result;
    }
157683
public function getEmbeddedAsset(Asset $asset)
	{
		$embeddedAsset = null;

		if ($asset->kind === Asset::KIND_JSON)
		{
			try
			{
				// Note - 2018-05-09
				// As of Craft 3.0.6 this can be replaced with $asset->getContents()
				// This version was released on 2018-05-08 so need to wait for majority adoption
				$fileContents = stream_get_contents($asset->getStream());
				$decodedJson = Json::decodeIfJson($fileContents);

				if (is_array($decodedJson))
				{
					$embeddedAsset = $this->createEmbeddedAsset($decodedJson);
				}
			}
			catch (Exception $e)
			{
				// Ignore errors and assume it's not an embedded asset
				$embeddedAsset = null;
			}
		}

		return $embeddedAsset;
	}
49997
public static function createFromArray(array $array)
    {
        self::$instance = new Collector;

        self::$instance->buffer = null;

        $spreadsheet = new Spreadsheet();
        $spreadsheet->getActiveSheet()
            ->fromArray(
                $array,  // os dados a adicionar
                NULL     // itens com este valor não serão setados
            );

        self::$instance->buffer = $spreadsheet;

        self::$instance->debug_info = ['created_with' => __METHOD__];

        return self::$instance;
    }
161952
protected function doCreateObject(array $array)
    {
        $orderItem = new WishListItem($array);
        if (isset($array['products']) && $product = reset($array['products'])) {
            $productMapper = new ProductsMapper();

            if (isset($array['images'])) {
                $product['images'] = $array['images'];
            }

            $orderItem->product = $productMapper->createObject($product);
        }

        return $orderItem;
    }
76968
public static function expandFromDotNotatedKeys(array $array) {
    $data = new Data();

    // @todo Make this work at all levels of array.
    foreach ($array as $key => $value) {
      $data->set($key, $value);
    }

    return $data->export();
  }