Map array to Invoice object.

@param $data

@return Invoice
197811
public function map($data): Invoice
    {
        $services = [];

        foreach ($data['services'] as $service) {
            $services[] = (new Invoice\Service())
                ->setId((int) $service['id'])
                ->setName($service['name'])
                ->setTaxSymbol($service['tax_symbol'])
                ->setUnit($service['unit'])
                ->setQuantity((float) $service['quantity'])
                ->setUnitNetPrice($this->mapPrice($service['unit_net_price']))
                ->setUnitNetPriceBeforeDiscount($this->mapPrice($service['unit_net_price_before_discount']))
                ->setNetPrice($this->mapPrice($service['net_price']))
                ->setGrossPrice($this->mapPrice($service['gross_price']))
                ->setTaxPrice($this->mapPrice($service['tax_price']))
                ->setSymbol($service['symbol'])
                ->setDiscount((float) $service['discount']);
        }

        $invoice = (new Invoice())
            ->setId((int) $data['id'])
            ->setNumber($data['number'])
            ->setInvoiceDate($this->mapDate($data['invoice_date']))
            ->setCurrency($data['currency'])
            ->setPaidPrice($this->mapPrice($data['paid_price']))
            ->setNotes($data['notes'])
            ->setKind($data['kind'])
            ->setPaymentMethod($data['payment_method'])
            ->setSellerSignature($data['seller_signature'])
            ->setRecipientSignature($data['recipient_signature'])
            ->setSaleDate($this->mapDate($data['sale_date']))
            ->setStatus($data['status'])
            ->setPaymentDate($this->mapDate($data['payment_date']))
            ->setPaidDate($this->mapDate($data['paid_date']))
            ->setNetPrice($this->mapPrice($data['net_price']))
            ->setTaxPrice($this->mapPrice($data['tax_price']))
            ->setGrossPrice($this->mapPrice($data['gross_price']))
            ->setClientId($data['client_id'] ? (int) $data['client_id'] : null)
            ->setClientCompanyName($data['client_company_name'])
            ->setClientStreet($data['client_street'])
            ->setClientCity($data['client_city'])
            ->setClientPostCode($data['client_post_code'])
            ->setClientTaxCode($data['client_tax_code'])
            ->setClientCountry($data['client_country'])
            ->setBankAccount($data['bank_account'])
            ->setBankName($data['bank_name'])
            ->setSwift($data['swift'])
            ->setVatExemptionReason($data['vat_exemption_reason'] ?: null)
            ->setSaleDate($this->mapDate($data['sale_date']))
            ->setSaleType($data['sale_type'])
            ->setInvoiceDateKind($data['invoice_date_kind'])
            ->setServices($services)
            ->setExtensions((new Invoice\Extension())
                ->setPayment((new Invoice\Extension\Payment())
                    ->setLink($data['extensions']['payments']['link'])
                    ->setAvailable($data['extensions']['payments']['available']))
                ->setShare((new Invoice\Extension\Share())
                    ->setLink($data['extensions']['shares']['link'])
                    ->setAvailable($data['extensions']['payments']['available'])
                    ->setValidUntil($this->mapDate($data['extensions']['shares']['valid_until'])))
            );

        return $invoice;
    }
757283
protected function transform($data)
    {

        $items = [
            'name'       => $data[ 'name' ],
            'final'      => $this->boolValue($data[ '@attributes.final' ]),
            'abstract'   => $this->boolValue($data[ '@attributes.abstract' ]),
            'static'     => $this->boolValue($data[ '@attributes.static' ]),
            'line'       => (int)$data[ '@attributes.line' ],
            'visibility' => $data[ '@attributes.visibility' ],
            'namespace'  => $data[ '@attributes.namespace' ],
            'package'    => $data[ '@attributes.package' ],

            'description'      => $this->createDescription($data[ 'docblock.description' ]),
            'long-description' => $this->createDescription($data[ 'docblock.long-description' ]),

            'returns' => [],
            'throws'  => [],

            'tags'      => [],
            'arguments' => [],
        ];


        $tags = $data->get('docblock.tag');
        if ( $tags !== null ) {
            // if only 1 tag
            if ( $data->has('docblock.tag.@attributes') ) {
                $tags = Collection::make([ $data->get('docblock.tag') ]);
            }
            $returnTag = $tags->where('@attributes.name', 'return');
            if ( $returnTag !== null ) {
                $returnType         = $returnTag->get('*.type', $returnTag->get('*.@attributes.type', []));
                $items[ 'returns' ] = is_array($returnType->first()) ? $returnType->first() : $returnType->toArray();
            }

            $throwsTags = $tags->where('@attributes.name', 'throws');
            if ( $throwsTags !== null ) {
                $throwsTags->each(function ($tag) use (&$items) {
                    $items[ 'throws' ][] = $tag[ 'type' ];
                });
            }
        }


        if ( $data[ 'name' ] = '' ) {
            $desc = $data->get('docblock.description', 'asdf ' . str_random(5));
            if ( is_array($desc) ) {
                $desc = implode("\n", $desc);
            }
            $data[ 'name' ] = camel_case(last(explode(' ', $desc)));
        }

        $items[ 'full_name' ]  = $data->get('full_name', $this->belongsTo[ 'class_name' ] . '::' . $data[ 'name' ]);
        $items[ 'class_name' ] = head(explode('::', $items[ 'full_name' ]));
        $items[ 'inherited' ]  = $this->belongsTo[ 'full_name' ] !== $items[ 'class_name' ];


        $this->items          = $items;
        $items[ 'tags' ]      = $this->structures('docblock.tag', Tag::class, $data);
        $items[ 'arguments' ] = $this->structures('argument', Argument::class, $data);

        foreach ( $items[ 'arguments' ] as $i => $argument ) {
            /** @var $argument Argument */
            $tag = $items[ 'tags' ]->where('variable', $argument[ 'name' ])->first();
            if ( $tag !== null ) {
                $items[ 'arguments' ][ $i ][ 'description' ] = $tag[ 'description' ];
            }
        }

        return $items;
    }
1288324
protected function toArrayRecursive($data)
    {
        $type = $data->getType();
        if (is_array($data->getValue())) {
            $result = [
                self::TYPE_LIST => [],
                'type'          => self::TYPE_LIST
            ];
            foreach ($data->getValue() as $key => $value) {
                if ($value instanceof $this) {
                    $result[self::TYPE_LIST][] = $data->toArrayRecursive($value);
                }
            }
            return $result;
        } else {
            return [
                $type  => $data->getValue(),
                'type' => $type,
            ];
        }
    }
129815
public function makeFromArray(array $data): \BearFramework\Emails\Email
    {
        return \BearFramework\Emails\Email::fromArray($data);
    }
69081
public static function createFromArray(array $data)
    {
        $self = new self();

        foreach ($data as $translation) {
            $self->addTranslation(Translation::createFromArray($translation));
        }

        return $self;
    }
151623
public static function createFromArray(array $data)
    {
        $self = new self();

        if (isset($data['id'])) {
            $self->setId($data['id']);
        }
        if (isset($data['name'])) {
            $self->setName($data['name']);
        }
        if (isset($data['plural'])) {
            $self->setPlural($data['plural']);
        }
        if (isset($data['data_type'])) {
            $self->setDataType($data['data_type']);
        }
        if (isset($data['tags'])) {
            $self->setTags($data['tags']);
        }

        return $self;
    }
635003
protected function toArrayRecursive($data)
    {

        if ($data instanceof RecordFieldValue) {
            return $data->toArrayRecursive($data);
        } else {
            return parent::toArrayRecursive($data);
        }
    }
564230
private function convertObjectToArray($data)
    {
        $converted = [];
        foreach($data as $key => $value) {
            if(is_object($value)) {
                $converted[$key] = $this->convertObjectToArray($value);
            } else {
                $converted[$key] = $value;
            }
        }

        return $converted;
    }
511154
protected function outputMany($data)
    {
        if (is_object($data)) {
            $data = $data->getRows();
        }

        $output = array();
        foreach ($data as $row) {
            $output[] = $this->outputOne($row);
        }

        return $output;
    }
1160319
protected function mapAttributes(array &$data)
    {
        $map = $this->attributeMap;
        $out = [];

        foreach ($data as $key => &$value) {
            if (isset($map[$key])) {
                $key = $map[$key];
            }
            $out[$key] = $value;
        }

        return $out;
    }
166208
public function normalizeFormData(array $data)
    {
        if (empty($data)) {
            return $data;
        }

        $renameMap = array_flip($this->renamemap);

        foreach ($renameMap as $customName => $defaultName) {
            if (array_key_exists($customName, $data)) {
                $value = $data[$customName];
                unset($data[$customName]);
                $data[$defaultName] = $value;
            }
        }

        return $data;
    }
350000
protected function transform($data)
    {
        $items = [
            'byref'       => (bool)$data[ '@attributes.by_reference' ],
            'types'       => explode('|', $this->createString($data[ 'type' ])),
            'description' => '',
        ];

        $this->copy([ 'name', 'default' ], $data, $items);
        //$data['default']
        return $items;
    }
236956
protected function toArray( $data )
    {
        if ( is_object( $data ) )
        {
            $data = (array) $data;
        }
        if ( is_array( $data ) )
        {
           foreach( $data as $key => $val )
           {
               $data[$key] = $this->toArray( $val );
           }
        }
        return $data;
    }
610294
public function map($data)
    {
        return (new BankAccount())
            ->setId((int) $data['id'])
            ->setBankName($data['bank_name'])
            ->setAccountNumber(str_replace(' ', '', $data['account_number']))
            ->setSwift($data['swift'] ?: null)
            ->setDefault($data['default']);
    }
1310940
protected function toArrayRecursive($data)
    {
        if (is_array($data) || is_object($data)) {
            $result = [];
            foreach ($data as $key => $value) {
                if ($key === "mappingClasses" || $key === "propNameMap") {
                    continue;
                }
                $propNameMap = $key;
                $obj = $this;
                if (is_object($data)) {
                    $obj = $data;
                }

                if (property_exists($obj, $propNameMap)) {
                    $ourPropertyName = array_search($propNameMap, $obj->propNameMap);

                    if ($ourPropertyName) {
                        $propNameMap = $ourPropertyName;
                    }
                }

                if (is_object($value) && method_exists($value, "getAll")) {
                    if (method_exists($obj, 'toArrayRecursive')) {
                        $result[$propNameMap] = $obj->toArrayRecursive($value->getAll());
                    }
                } else if ($value !== null) {
                    if (method_exists($obj, 'toArrayRecursive')) {
                        $result[$propNameMap] = $obj->toArrayRecursive($value);
                    }
                }
            }
            return $result;
        }
        return $data;
    }
969600
public function transform($data)
    {
        if (is_array($data)) {
            return $data;
        }

        if (is_object($data) && $data instanceof Arrayable) {
            return $data->toArray();
        }

        return (array) $data;
    }
969320
protected function fromArray( array $data )
	{
		$data['customer.label'] = $data['customer.firstname'] . ' ' . $data['customer.lastname'];
		$data['customer.code'] = $data['customer.email'];

		$manager = \Aimeos\MShop::create( $this->getContext(), 'customer' );

		if( isset( $data['customer.id'] ) && $data['customer.id'] != '' ) {
			$item = $manager->getItem( $data['customer.id'], $this->getDomains() );
		} else {
			$item = $manager->createItem();
		}

		$item->fromArray( $data, true );
		$item->setGroups( array_intersect( array_keys( $this->getGroupItems() ), $item->getGroups() ) );

		return $item;
	}