Create new Quotation line from data
@param array $data
436671
public function add(array $data)
    {
        $defaults = array(
            "description" => null,
            "price"       => null,
            "discount"    => null,
            "qty"         => 1,
            "unit"        => null
        );

        $merged = array_merge($defaults, $data);

        $line = $this->create($this->quotationHandle);

        if( isset($merged['product']) )
        {
            $this->product($line, $merged['product']);
            unset( $merged['product'] );
        }

        foreach( $merged as $name => $value )
        {
            if( is_null($value) )
                continue;

            switch($name)
            {
                case 'description':
                    $this->description($line, $value);
                    break;
                case 'price':
                    $this->price($line, $value);
                    break;
                case 'discount':
                    $this->discount($line, $value);
                    break;
                case 'qty':
                    $this->qty($line, $value);
                    break;
                case 'unit':
                    $this->unit($line, $value);
                    break;
            }
        }
    }
924571
public static function create(array $data)
    {
        $token = new self();
        foreach ($data as $key => $value) {
            $key = self::underscore2CamelCase($key);
            if (property_exists($token, $key)) {
                $token->{$key} = $value;
            }
        }
        return $token;
    }
194987
public function updateTranslation(array $data)
    {
        $translation = $this->translations()->where([
            'record_id' => $this->id,
            'language_code' => Arr::get($data, 'language_code'),
        ])->first();

        if (is_null($translation)) {
            $translation = $this->translations()->create($data);
        } else {
            $translation->update($data);
        }

        return $translation;
    }
532556
public function create(array $data)
    {
        $model = $this->app->make($this->model());
        $model->fill($data);

        $wasSaved = $model->save();

        if ($wasSaved) {
            return $this->find($model->id);
        }

        $errorMessage = "Não foi possível salvar.";

        if (method_exists($model, 'isValid')) {
            $exception = new ValidationException();
            $exception->setMessages($model->getValidationErrors()->all());

            throw $exception;
        }
        throw new ApiException($errorMessage);

    }
30238
public function initFromArray(array $data) {

        $unknownFields = [];

        foreach ($data as $k => $v) {

            if (empty($v)) {
                continue;
            }

            $setter = 'set' . ucfirst(str_replace('_', '', ucwords($k, '_')));

            if (method_exists($this, $setter)) {
                $this->{$setter}($v);
                continue;
            }

            $unknownFields[$k] = $v;

        }

        if (!empty($unknownFields)) {
            trigger_error('Encountered unknown fields in response: ' . json_encode($unknownFields));
        }

        return $this;

    }
276
public function create(array $data)
    {
        if (! array_key_exists('name', $data)) {
            $data['name'] = Str::slug($data['display_name']);
        }

        return parent::create($data);
    }
428509
protected function _create(array $data) {
        $this->_validateLoadable();
        $snippetModel = new Model_Snippet();
        try {
            $snippetID = $snippetModel->insert($data);
            $snippet = $snippetModel->fetchRow(
                $snippetModel->select()->where('id = ?', $snippetID)
            );
            return $snippet;
        } catch (Garp_Model_Validator_Exception $e) {
            Garp_Cli::errorOut($e->getMessage());
        }
    }
884407
public static function createFromData(array $data)
    {
        if (!isset($data['formula'])) {
            throw new DomainException(self::REQUIRED_FORMULA);
        }

        switch ($data['formula']) {
            case self::FLAT_RATE:
                return new Pricing\FlatRate($data);
            case self::FIXED_FEE:
                return new Pricing\FixedFee($data);
            case self::STAIRSTEP:
                return new Pricing\Stairstep($data);
            case self::TIERED:
                return new Pricing\Tiered($data);
            case self::VOLUME:
                return new Pricing\Volume($data);
            default:
                throw new DomainException(sprintf(self::UNSUPPORTED_FORMULA, implode(',', self::getAvailableFormulas())));
        }
    }
882338
public function create_sql_insert_string(array $data) {
		#$retval = "";
		if(is_array($data) && count($data)) {
			$fields = "";
			$values = "";
			foreach($data as $k=>$v) {
				$fields = ToolBox::create_list($fields, $k, ", ");
				$values = ToolBox::create_list($values, ':'. $k, ", ");
			}
			if(strlen($fields) && strlen($values)) {
				$retval = ' ('. $fields .') VALUES ('. $values .')';
			}
			else {
				throw new Exception(__METHOD__ .": no fields (". $fields .") or values (". $values .") created... ". $this->gfObj->debug_print($data,0));
			}
		}
		else {
			throw new Exception(__METHOD__ .": unable to create insert string, no fields given");
		}
		
		return($retval);
	}
1040716
private function generateDefaultLine(array $data): string
    {
        return sprintf('    '.'<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%s</priority></url>'."\n", $data['url'], date('Y-m-d', strtotime($data['lastmod'])), $data['changefreq'], $data['priority']);
    }
1087463
private function normalizeArrayForNewLines(array $data) {
		foreach($data as $k => $item) {
			if(is_string($item)) {
				$data[$k] = str_replace(["\r\n", "\n\r", "\r"], "\n", $item);
			} elseif(is_array($item)) {
				$data[$k] = $this->normalizeArrayForNewLines($item);
			}
		}
		return $data;
	}
1374487
protected function fromArray($data)
    {
        if (empty($data)) {
            return $this;
        }

        $this->data = array_replace_recursive($this->data, $data);

        return $this;
    }
858671
private function genInsert(array $data): string
    {
        // Current table
        $table = $this->getCollection();

        // Generate array of fields for insert
        $fieldNames = implode(',', array_keys($data));

        // Generate line with data for update
        $fieldDetails = ':' . implode(', :', array_keys($data));

        return "INSERT INTO $table ($fieldNames) VALUES ($fieldDetails)";
    }
635918
protected function createReceiveTextMsg(array $data)
    {
        $result = new WxReceiveTextMsg();
        $this->initReceiveMsg($result, $data);
        if (isset($data['Content'])) {
            if (!is_string($data['Content'])) {
                Helper::getLogWriter()->debug("[createReceiveTextMsg]" . serialize($data));
                $data['Content'] = '';
            }
        }

        $result->setContent(isset($data['Content']) ? trim($data['Content']) : '');
        return $result;
    }
935715
public static function create(array $data): Location
    {
        $location = new Location();
        parent::fill($data, $location);
        return $location;
    }
887403
public static function createFromData(array $data)
    {
        if (!isset($data['method'])) {
            throw new DomainException('Method is required');
        }
        switch ($data['method']) {
            case PaymentMethod::METHOD_PAYMENT_CARD:
                $paymentInstrumentValidation = new PaymentCardValidation($data);

                break;
            default:
                throw new DomainException(
                    sprintf('Unexpected method. Only %s methods support', implode(',', self::$supportMethods))
                );
        }

        return $paymentInstrumentValidation;
    }
1151601
public static function fromArray(array $data)
    {
        return new PhpCsFixer(
            new Undefined(false),
            new Enabled($data['enabled']),
            PhpCsFixerLevelsFactory::fromArray($data['levels']),
            new PhpCsFixerOptions(isset($data['options']) ? $data['options'] : null)
        );
    }