Retrieves the addresses from a specific field in a part

@param string $field
@param Part   $part

@return array
353001
private function getAddressesFromFieldInPart($field, Part $part)
    {
        $addresses = [];

        $headers = $part->getHeaders();
        if (empty($headers)) {
            return $addresses;
        }

        if (!$headers->has($field)) {
            return $addresses;
        }

        /** @var AbstractAddressList $addressList */
        $addressList = null;

        try {
            $addressList = $part->getHeader($field);
        } catch (InvalidArgumentException $e) {
            return $addresses;
        }

        if (!$addressList instanceof AbstractAddressList) {
            return $addresses;
        }

        foreach ($addressList->getAddressList() as $address) {
            $addresses[] = strtolower($address->getEmail());
        }

        return $addresses;
    }
948754
public function getParts()
    {
        if (is_null($this->value)) {
            return [];
        } elseif (is_array($this->value)) {
            return $this->value;
        } else {
            return [$this->value];
        }
    }
1249067
public function getIndexData(Field $field, FieldDefinition $fieldDefinition)
    {
        return array(
            new Search\Field(
                'value_address',
                $field->value->externalData['address'],
                new Search\FieldType\StringField()
            ),
            new Search\Field(
                'value_location',
                array(
                    'latitude' => $field->value->externalData['latitude'],
                    'longitude' => $field->value->externalData['longitude'],
                ),
                new Search\FieldType\GeoLocationField()
            ),
            new Search\Field(
                'fulltext',
                $field->value->externalData['address'],
                new Search\FieldType\FullTextField()
            ),
        );
    }
345253
public function attributes($field)
    {
        $parts = explode('.', $field);
        $table = $this->_getTable($parts);
        $column = (array)$table->getSchema()->getColumn(array_pop($parts));
        $whitelist = ['length' => null, 'precision' => null];

        return array_intersect_key($column, $whitelist);
    }
700455
private function parseAddresses($list) {
        $addresses = [];

        foreach ($list as $item) {
            $address = (object) $item;

            if (!property_exists($address, 'mailbox')) {
                $address->mailbox = false;
            }
            if (!property_exists($address, 'host')) {
                $address->host = false;
            }
            if (!property_exists($address, 'personal')) {
                $address->personal = false;
            }

            $personalParts = imap_mime_header_decode($address->personal);

            $address->personal = '';
            foreach ($personalParts as $p) {
                $address->personal .= $p->text;
            }

            $address->mail = ($address->mailbox && $address->host) ? $address->mailbox.'@'.$address->host : false;
            $address->full = ($address->personal) ? $address->personal.' <'.$address->mail.'>' : $address->mail;

            $addresses[] = $address;
        }

        return $addresses;
    }
238549
protected function _splitFieldname($field) {
		$regex = '/^([a-z0-9_-]+)\.([a-z 0-9_-]+|\*)$/iS';

		if (strpos($field, '.') !== false && preg_match($regex, $field, $matches)) {
			return [$matches[1], $matches[2]];
		}
		return [null, $field];
	}
119815
protected function _WhereFromOrderBy($Part, $Comment, $Op = '') {
      if (!$Op || $Op == '=')
         $Op = ($Part[1] == 'desc' ? '>' : '<').$Op;
      elseif ($Op == '==')
         $Op = '=';
      
      $Expr = $Part[0].' '.$Op;
      if (preg_match('/c\.(\w*\b)/', $Part[0], $Matches))
         $Field = $Matches[1];
      else
         $Field = $Part[0];
      $Value = GetValue($Field, $Comment);
      if (!$Value)
         $Value = 0;

      return array($Expr, $Value);
   }
542185
public function getByRequestParts(
        string $host,
        string $method,
        RequestParts $requestParts
    ): array {
        $json = json_encode($requestParts->getParameters()['json']);
        $formattedUrl = rtrim($host, '/').'/'.ltrim($requestParts->getUrl(), '/');
        $method = strtoupper($method);
        $headers = [];
        foreach ($requestParts->getParameters()['headers'] ?? [] as $header => $value) {
            $headers[] = "$header: $value";
        }

        $c = curl_init();
        curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($c, CURLOPT_URL, $formattedUrl);
        curl_setopt($c, CURLOPT_HEADER, false);
        curl_setopt($c, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($c, CURLOPT_ENCODING, 'gzip, deflate');

        if (!in_array($method, ['GET', 'HEAD'])) {
            curl_setopt($c, CURLOPT_POSTFIELDS, $json);
            $headers[] = 'Content-Type: application/json';
            $headers[] = 'Content-Length: '.strlen($json);
        }

        curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
        $content = curl_exec($c);
        $responseCode = curl_getinfo($c, CURLINFO_HTTP_CODE);
        curl_close($c);

        if (
            'HEAD' !== $method &&
            false === $content
        ) {
            throw ConnectionException::buildConnectExceptionByUrl($requestParts->getUrl());
        }

        return [
            'code' => (int) $responseCode,
            'body' => empty($content)
                ? []
                : json_decode($content, true),
        ];
    }
1009254
public function getBinds($parts = [], $clear = false)
    {
        $binds = [];

        if (!is_array($parts)) {
            $parts = [$parts];
        }

        if (!$parts) {
            $parts = array_keys($this->bind);
        }

        foreach ($parts as $part) {
            if (!isset($this->bind[$part])) {
                continue;
            }

            foreach ($this->bind[$part] as $key => $bind) {
                $binds[] = $bind;
                if ($clear) {
                    unset($this->bind[$part][$key]);
                }
            }
        }

        return $binds;
    }
120388
public function lists($field)
    {
        $l = [];
        foreach ($this->results as $r) {
            $v = $r->get($field);
            if ($v and !$r->isRestricted($field)) {
                $l[] = $v;
            }
        }
        return $l;
    }
1297393
protected function hasHeader(Part $part, $header)
    {
        if (count($part->getHeaders()) < 1) {
            return false;
        }

        return $part
            ->getHeaders()
            ->has($header);
    }
1053971
public function values($field)
    {
        $values = [];
        foreach ($this->distinct()->select([$field])->all() as $v) {
            $values[] = $v[$field];
        }

        return $values;
    }
1118404
public function toQueryParts(): array
    {
        $fields = [];
        foreach ($this->fields as $field => $value) {
            $fields['by'.ucfirst($field)] = $value;
        }

        return $fields;
    }
912750
private function getFields($field)
    {
        if ($field instanceof Group || $field instanceof Fieldset) {
            $elements = $field->getFields();
        } elseif ($field instanceof AbstractField) {
            $elements = [$field];
        } else {
            throw new \InvalidArgumentException(sprintf(
                "Invalid type '%s'",
                is_object($field) ? get_class($field) : gettype($field)
            ));
        }

        return $elements;
    }
93416
protected function get($parts, $subject)
    {
        $part = array_shift($parts);

        if (!$this->has($part, $subject)) {
            $type = is_object($subject) ? get_class($subject) : gettype($subject);
            throw new \Exception(sprintf("Can't find %s in %s", $part, $type));
        } elseif (is_array($subject)) {
            $value = $subject[$part];
        } elseif (method_exists($subject, $part)) {
            $value = call_user_func(array($subject, $part));
        } else {
            $value = $subject->$part;
        }

        if (count($parts) == 0) {
            return $value;
        } else {
            return $this->get($parts, $value);
        }
    }
1332259
public function visit(Expr\Part $expr)
    {
        $response = null;
        foreach($visitors as $visitor) {
            $response = $visitor->visit($expr);
        }

        return $response;
    }
868459
public function fetchAllOf(string $field): array
    {
        $array = [];
        foreach ($this->fetchAllGenerator() as $record) {
            $array[] = $record[$field] ?? null;
        }

        return $array;
    }