Instantiates a new record
@param array $record
@return object
163841
final public static function instantiate (array $record)
	{
		$className 	= get_called_class();
		$object 	= new $className;
		foreach ($record as $attribute => $value):
			$object->$attribute = $value;
		endforeach;
		return $object;
	}
596368
public function format(array $record)
    {
        $record = parent::format($record);

        $record['tags'] = [];
        $record['custom_data'] = [];
        $record['timestamp'] = null;

        foreach (['extra', 'context'] as $source) {
            if (array_key_exists('tags', $record[$source]) && is_array($record[$source]['tags'])) {
                $record['tags'] = array_merge($record['tags'], $record[$source]['tags']);
            }
            if (array_key_exists('timestamp', $record[$source]) && is_numeric($record[$source]['timestamp'])) {
                $record['timestamp'] = $record[$source]['timestamp'];
            }
            unset($record[$source]['tags'], $record[$source]['timestamp']);
        }

        $record['custom_data'] = $record['extra'];
        $record['extra'] = [];
        foreach ($record['context'] as $key => $item) {
            if (!in_array($key, ['file', 'line', 'exception'])) {
                $record['custom_data'][$key] = $item;
                unset($record['context'][$key]);
            }
        }

        return $record;
    }
1344966
protected function write(array $record) {
        if ($this->exception) {
            throw $this->exception;
        }

        $this->stream->write((string) $record['formatted'])->onResolve($this->onResolve);
    }
614666
private function detectRecord($record)
    {
        foreach ($this->recordTypes as $recordType) {
            $method = new ReflectionMethod($recordType, 'match');
            $arguments = [$record];

            if ($method->invokeArgs(null, $arguments) === false) {
                continue;
            }

            $class = $method->getDeclaringClass();

            return ($class->hasMethod('__construct'))
                ? $class->newInstanceArgs($arguments) : $class->newInstance();
        }

        throw new UnexpectedValueException();
    }
891766
public function processRecord(array $record)
    {
        if (is_null($this->requestId)) {
            $this->requestId = uniqid('');
        }

        $record['extra']['requestId'] = $this->requestId;

        return $record;
    }
1089055
protected static function fromMongoObjects($record)
    {
        if ($record instanceof BSONDocument) {
            $record = $record->getArrayCopy();
        } elseif (is_object($record)) {
            $record = (array)$record; // std object
        }
        if (!empty($record)) {
            foreach ($record as &$data) {
                if (is_object($data)) {
                    if ($data instanceof ObjectID) {
                        $data = (string)$data;
                    } elseif ($data instanceof Timestamp) {
                        $data = (string)$data;
                    } elseif ($data instanceof UTCDateTime) {
                        if (empty($cfgFormat = DataFormatter::getDateTimeFormat('datetime'))) {
                            $cfgFormat = 'c';
                        }
                        $data = $data->toDateTime();
                        $data = ['$date' => $data->format($cfgFormat)];
                    } elseif ($data instanceof Binary) {
                        $data = $data->getData();
                    }
                }
            }
        }

        return $record;
    }
186203
protected static function extract_item_record_from_record(stdClass $record) {
        $newrec = new stdClass();
        foreach ($record as $key => $value) {
            if (strpos($key, 'item') !== 0) {
                continue;
            }
            $key = substr($key, 4);
            $newrec->{$key} = $value;
        }
        return $newrec;
    }
687286
public static function insert($record)
    {
        $instance = new static();
        if ($fields = array_diff(array_keys($record), $instance->_di->modelsMetadata->getAttributes($instance))) {
            $instance->logger->debug(['insert `:1` table skip fields: :2', $instance->getSource(), array_values($fields)]);

            foreach ($fields as $field) {
                unset($record[$field]);
            }
        }

        $instance->getConnection($record)->insert($instance->getSource($record), $record);

        return 1;
    }
698216
public function assignRecord(array $record, DB $database)
    {
        $dao = $this->getDAO();
        $table = $dao->getTable($database);
        $pkey = $table->getPrimaryColumns();
        if ($pkey !== null)
        {
            $this->_id = array();
            foreach ($pkey as $col)
                $this->_id[$col->getName()] = $record[$col->getName()];
        }
        else
            $this->_id = null;

        $this->_record = $record;
        $this->_changed = array();
        $this->setSourceDB($database);
        $this->init();

        $columns = $table->getColumns($database);
        foreach ($columns as $name => $def)
        {
            if (!array_key_exists($name, $this->_record))
                continue;

            $this->_record[$name] = $def->afterFetchFilter($this->_record[$name]);
            
            // Synchronize local variables
            if (property_exists($this, $name))
                $this->$name = $this->_record[$name];
        }
        return $this;
    }
983507
protected function filterRecord(array $record)
    {
        foreach ($this->filteredKeys as $key) {
            if (isset($record[$key]) {
                unset($record[$key]);
            }
        }
        
        // Convert datetime object to string
        if (! isset($record['datetime'])) {
            $record['datetime'] = new \DateTime("now");
        }
        $record['datetime'] = $record['datetime']->format(self::DATE_FORMAT);

        return $record;
    }
206857
protected function addRecord(array $record)
    {
        return $this->document->fputcsv($record, $this->delimiter, $this->enclosure, $this->escape);
    }
1243015
final public function from_record(stdClass $record) {
        $record = (array) $record;
        foreach ($record as $property => $value) {
            $this->raw_set($property, $value);
        }
        return $this;
    }
1013090
public static function fromRecord($record)
    {
        if (!$record) {
            return null;
        }
        $className = get_called_class();
        $entity = new $className;
        foreach ($record as $key => $value) {
            $entity->$key = $value;
        }
        return $entity;
    }
1334317
protected static function _getRecordClass($record)
    {
        $static = get_called_class();

        if (!static::fieldExists('Class')) {
            return $static;
        }

        $columnName = static::_cn('Class');

        if (!empty($record[$columnName]) && is_subclass_of($record[$columnName], $static)) {
            return $record[$columnName];
        } else {
            return $static;
        }
    }
524547
protected function write(array $record)
    {
    	$uri = $this->getUri();

    	if (empty($uri)) {
    		return;
    	}

    	$request = $this->getMessageFactory()->createRequest(
    		$this->getMethod(),
    		$this->getUri(),
    		$this->getHeaders(),
    		$record['formatted'],
    		$this->getProtocolVersion()
    	);

    	try {
    		$this->getHttpClient()->sendRequest($request);
    	/* istanbul ignore next */
    	} catch (\Exception $e) {
    		// QUESTION(msschl): How to handle the thrown exceptions???
    		/* istanbul ignore next */
    		return;
    	}
    }
1070376
private function decodeResult(array $record): AbstractResult
    {
        $record = $this->preParse($record);

        if ($this->isValidResult($record)) {
            $unit = new Result($record['id'], $record['result']);
        } elseif ($this->isValidError($record)) {
            $exceptionClass = $this->exceptionMap[$record['error']['code']] ?? ServerErrorException::class;
            $unit = new Error($record['id'], new $exceptionClass(
                $record['error']['data']['message'] ?? $record['error']['message'] ?? 'Server error',
                $record['error']['data']['code'] ?? 0
            ));
        } else {
            throw new InvalidResponseException();
        }

        return $unit;
    }
895546
public function mergeRecord($record) {
    if ($this->isNew()) {
      throw new \Exception('Can not merge, is new');
    }
    foreach ($this->fields as $field_name => $field) {
      if (!empty($record[$field_name])) {
        $this->record[$field_name] = $record[$field_name];
      }
      $this->isDirty = TRUE;
    }

    return $this;
  }