@param array        $record
@param string|array $include  List of keys to include in the output record
@param string|array $id_field Single or list of identifier fields

@return array
961777
protected static function cleanRecord($record = [], $include = '*', $id_field = self::DEFAULT_ID_FIELD)
    {
        if ('*' == $include) {
            return $record;
        }

        //  Check for $record['_id']
        $id = array_get($record, $id_field,
            //  Default to $record['id'] or null if not found
            array_get($record, 'id')
        );

        //  Check for $record['_rev']
        $rev = array_get($record, static::REV_FIELD,
            //  Default if not found to $record['rev']
            array_get($record, 'rev',
                //  Default if not found to $record['value']['rev']
                array_get($record, 'value.rev')
            )
        );

        $out = [$id_field => $id, static::REV_FIELD => $rev];

        if (empty($include)) {
            return $out;
        }

        if (!is_array($include)) {
            $include = array_map('trim', explode(',', trim($include, ',')));
        }

        foreach ($include as $key) {
            if (0 == strcasecmp($key, $id_field) || 0 == strcasecmp($key, static::REV_FIELD)) {
                continue;
            }
            $out[$key] = array_get($record, $key);
        }

        return $out;
    }
162552
public function get_document($record, $options = array()) {
        return parent::get_document($record, array('user1id' => $record->useridto, 'user2id' => $record->useridfrom));
    }
620369
private static Field recordIdFieldIn(Class klass) {
        for (Field field : klass.getDeclaredFields()) {
            if (field.isAnnotationPresent(RecordId.class)) {
                return field;
            }
        }
        Class superclass = klass.getSuperclass();
        if (superclass != null) {
            return recordIdFieldIn(superclass);
        }
        throw new RecordIdNotFoundException(klass);
    }
452505
public function getTranslatableForeignKeys(Record $record)
    {
        return [
            $this->primaryKey                => $record->{$this->primaryKey},
            $this->translatableLanguageField => $this->translatableLang->langId(),
        ];
    }
728892
function get_record($id, $assoc = false)
    {
        // return cached result
        if ($this->result && ($first = $this->result->first()) && $first[$this->primary_key] == $id) {
            return $assoc ? $first : $this->result;
        }

        $this->db->query(
            "SELECT * FROM " . $this->db->table_name($this->db_name, true).
            " WHERE `contact_id` = ?".
                " AND `user_id` = ?".
                " AND `del` <> 1",
            $id,
            $this->user_id
        );

        $this->result = null;

        if ($sql_arr = $this->db->fetch_assoc()) {
            $record = $this->convert_db_data($sql_arr);
            $this->result = new rcube_result_set(1);
            $this->result->add($record);
        }

        return $assoc && $record ? $record : $this->result;
    }
267460
private function translateRecordIntoEventMessage(array $record)
    {
        $identifier = new MessageIdentifier($record['event_id']);

        $payload = $this->eventSerializer->deserializePayload(
            $record['event_payload'],
            Contract::createFromClassName($record['event_payload_type'])
        );

        $metadata = $this->eventSerializer->deserializeMetadata(
            $record['event_metadata'],
            Contract::createFromClassName($record['event_metadata_type'])
        );

        $sequenceNumber = (int) $record['aggregate_version'];

        $eventMessage = new GenericEvent($this->aggregateRootIdentifier, $sequenceNumber, $identifier, $payload, $metadata);

        return $eventMessage;
    }
1198382
protected function processRecord(array $record): array
    {
        foreach ($this->processors as $processor) {
            $record = $processor($record);
        }

        return $record;
    }
422111
public function pushRecord(Record $record)
    {
        $this->records[] = $record;

        if (!$record->getType()->isStdin() || $record->getContent()) {
            return;
        }

        return $this->buildRequest();
    }
206857
protected function addRecord(array $record)
    {
        return $this->document->fputcsv($record, $this->delimiter, $this->enclosure, $this->escape);
    }
690709
protected function getOutputRecord(array $record)
    {
        // Adds the basic log details.
        $output = [
            static::DATETIME_OFFSET => $record['datetime']->format(static::DATETIME_FORMAT),
            static::SEVERITY_OFFSET => $record['level_name'],
            static::CONTENT_OFFSET  => $record['message'],
        ];

        // Adds the context file.
        if (isset($record['context']['file'])) {
            $output[static::FILE_OFFSET] = $record['context']['file'];
        }

        // Adds the context line.
        if (isset($record['context']['line'])) {
            $output[static::LINE_OFFSET] = $record['context']['line'];
        }

        // Adds the stack information.
        if (isset($record['extra'][EnvironmentProcessorAbstract::LOG_STACK])) {
            $output[static::STACK_OFFSET] = $record['extra'][EnvironmentProcessorAbstract::LOG_STACK];
        }

        // Adds the trace information.
        if (isset($record['extra'][BacktraceProcessor::TRACE_OFFSET])) {
            $output[static::TRACE_OFFSET] = $record['extra'][BacktraceProcessor::TRACE_OFFSET];
        }

        return $output;
    }
1213295
private function excludeFields(array $record): array
    {
        foreach ($this->excludeFields as $field) {
            $keys = explode('.', $field);
            $node = &$record;
            $lastKey = end($keys);
            foreach ($keys as $key) {
                if (!isset($node[$key])) {
                    break;
                }
                if ($lastKey === $key) {
                    unset($node[$key]);
                    break;
                }
                $node = &$node[$key];
            }
        }

        return $record;
    }
1164646
public static function transform($record, $includes = [])
    {
        $model_name = class_basename(get_class($record));
        $transformer = sprintf('\App\Transformers\%sTransformer', $model_name);

        $fractal = new self();

        if ($includes) {
            $fractal->manager->parseIncludes($includes);
        }

        try {
            return $fractal->item($record, new $transformer, $model_name);
        } catch (\Exception $e) {
            //Transformer class doesn't exist
            return [];
        }
    }
1069405
public function saveInclude($include_name, array $include_fields = [ ]) {
        $data = $include_fields;
        $data['include'] = $include_name;
        return $this->apiPost('include', $data);
    }
87020
public function addDataSource($record, $source)
    {
        if (arrayable($record)) {
            $record = $record->toArray();
        }

        if (! isset($record[$field = 'data_sources'])) {
            $record['data_sources'] = [];
        }

        $record['data_sources'][] = $source;

        return coollect($record);
    }
52692
private function insertRecord(string $id, string $key, string $value) : void
    {
        $query = sprintf(
            'INSERT INTO %s (%s, %s, %s, %s) VALUES(?, ?, ?, ?)',
            $this->options['table-name'],
            $this->options['id-column'],
            $this->options['key-column'],
            $this->options['value-column'],
            $this->options['last-access-column']
        );

        $statement = $this->pdo->prepare($query);
        $statement->execute([$id, $key, $value, time()]);
    }
173749
public function getRecordsToSubstitute(Application $app, $includeReason = false)
    {
        $merged = [];
        /** @var LazaretCheck $check */
        foreach($this->getChecks() as $check) {
            /** @var record_adapter $record */
            $conflicts = $check->listConflicts($app);
            foreach ($conflicts as $record) {
                if($includeReason) {
                    if (!array_key_exists($record->getRecordId(), $merged)) {
                        $merged[$record->getRecordId()] = [
                            'record' => $record,
                            'reasons' => []
                        ];
                    }
                    $merged[$record->getRecordId()]['reasons'][$this->getCheckerName($check)] = $check->getReason($app['translator']);
                }
                else {
                    $merged[$record->getRecordId()] = $record;
                }
            }
        }

        return $merged;
    }
343832
private void fetchMissingRecords() throws IOException {
        logger.debug("Records includes:");
        records.forEach(r -> logger.debug("{}", r));
        for (PtrRecord ptr : records.stream().filter(r -> r instanceof PtrRecord).map(r -> (PtrRecord) r).collect(Collectors.toList())) {
            fetchMissingSrvRecordsFor(ptr);
            fetchMissingTxtRecordsFor(ptr);
        }
        for (SrvRecord srv : records.stream().filter(r -> r instanceof SrvRecord).map(r -> (SrvRecord) r).collect(Collectors.toList())) {
            fetchMissingAddressRecordsFor(srv);
        }
    }