Return a new field based on its array representation.

@throws InvalidArgumentException Missing `tag', `occurrene', or `subfields' index
@param  array $field Array representation of a field
@return \HAB\Pica\Record\Field A shiny new field
426738
public static function factory (array $field) 
    {
        foreach (array('tag', 'occurrence', 'subfields') as $index) {
            if (!array_key_exists($index, $field)) {
                throw new InvalidArgumentException("Missing '{$index}' index in field array");
            }
        }
        return new Field($field['tag'],
                         $field['occurrence'],
                         array_map(array('HAB\Pica\Record\Subfield', 'factory'), $field['subfields']));
    }
111292
public function build_field($field)
	{
		! $field instanceof Fieldset_Field && $field = $this->field($field);

		return $field->build();
	}
1212972
public function setFieldsFromArray(Array $fields) {
    foreach ($fields as $field => $value) {
      $this->set($field, $value);
    }
    return $this;
  }
1306656
function create_field( $field )
	{
		// vars
		$o = array( 'id', 'class', 'name', 'value', 'placeholder' );
		$e = '';
		
		
		// prepend
		if( $field['prepend'] !== "" )
		{
			$field['class'] .= ' acf-is-prepended';
			$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
		}
		
		
		// append
		if( $field['append'] !== "" )
		{
			$field['class'] .= ' acf-is-appended';
			$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
		}
		
		
		$e .= '<div class="acf-input-wrap">';
		$e .= '<input type="email"';
		
		foreach( $o as $k )
		{
			$e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';	
		}
		
		$e .= ' />';
		$e .= '</div>';
		
		
		// return
		echo $e;
	}
525960
public function addFields($fields)
    {
        foreach ($fields as $field) {
            if (is_array($field)) {
                $this->addField(...$field);
            } else {
                $this->addField($field);
            }
        }

        return $this;
    }
492104
public function field($field, $prefix = null)
    {
        if (is_array($field)) {
            $field = new Field($field);
        }

        if (! $field instanceof FieldInterface) {
            throw new Exception('Field must implement interface '.FieldInterface::class.' or be an array.');
        }

        $formField = $this->getRegistrar()->resolve($field);

        if ($prefix) {
            $formField->setPrefix($prefix);
        }

        return $formField;
    }
1051544
static public function replaceArrayKey($arr = [],$field = '')
    {
        $newArr = [];
        if($arr){
            foreach ($arr as $value) {
                $newArr[$value[$field]] = $value;
            }
        }
        return $newArr;
    }
1352343
public function getRelationshipKey($field)
	{
		$model = $this->config->getDataModel();
		$invalidArgument = new \InvalidArgumentException("The '" . $field . "' relationship field you supplied for " .
								$this->config->getOption('name') . " is not a valid relationship method name on the supplied Eloquent model");

		//check if the related method exists on the model
		if (!method_exists($model, $field))
		{
			throw $invalidArgument;
		}

		//now that we know the method exists, we can determine if it's multiple or single
		$related_model = $model->{$field}();

		//check if this is a valid relationship object, and return the appropriate key
		if (is_a($related_model, $this->relationshipBase.'BelongsTo'))
		{
			return 'belongs_to';
		}
		else if (is_a($related_model, $this->relationshipBase.'BelongsToMany'))
		{
			return 'belongs_to_many';
		}
		else if (is_a($related_model, $this->relationshipBase.'HasOne'))
		{
			return 'has_one';
		}
		else if (is_a($related_model, $this->relationshipBase.'HasMany'))
		{
			return 'has_many';
		}
		else
		{
			throw $invalidArgument;
		}
	}
580165
public function array_fields($array, array $fields){
        $newArray= array();
        foreach ($array as $value) {
            $newValue= array();
            foreach ($fields as $key) {
                if(array_key_exists($key, $value)){
                    $newValue[$key]= $value[$key];
                }
            }
            $newArray[]= $newValue;
        }        
        return $newArray;
    }
1292068
public function get($className, $field)
    {
        foreach ($this->cursorClassName as $key => $cursor) {
            if ($cursor === $className && $field === $this->collections[$key]->getField()) {
                return $this->collections[$key];
            }
        }

        throw new \InvalidArgumentException(sprintf('Collection "%s" with "%s" field have not be apppend.', $className, $field));
    }
1036463
public function fields(array $fields)
    {
        foreach ($fields as $field) {
            if ($field instanceof Mapper) {
                $this->addFieldFromMapper($field);
                continue;
            }
            $this->fields[] = $field;
        }

        return $this;
    }
966492
public function create(array $fields)
    {
        $this->assertValidFields($fields);

        $request = new Request('customizations');
        $request->setParams(['fields' => $fields]);

        $response = $this->client->post($request);

        $this->assertSuccessResponse($response);

        return $response->getData();
    }
1268991
public function orderBy($field, $order)
    {
        if (!in_array($field, $this->getAvailableFields())) {
            throw new \InvalidArgumentException(sprintf('Field "%s" not supported, prefer: %s', $field, implode(', ', $this->getAvailableFields())));
        }

        if (!in_array($order, array('ASC', 'DESC'))) {
            throw new \InvalidArgumentException(sprintf('Order "%s" not supported, prefer: ASC or DESC', $order));
        }

        $this->sort = array($field, $order);

        return $this;
    }
1095919
public function select(array $fields)
    {
        if (empty($fields)) {
            throw new InvalidArgumentException('The field array must not be' .
                ' empty.');
        }

        foreach ($fields as $field) {
            $validationResult = QueryValidator::validateFieldName($field);
            if ($validationResult->isFailed()) {
                throw new InvalidArgumentException('The field array for' .
                    ' building the SELECT clause contains invalid field name.' .
                    ' Validation fail reason: ' .
                    $validationResult->getFailReason());
            }
        }

        // Flipping an array will create a new associative array. The keys of
        // the new associative array make a set of distinct fields.
        $distinctFields = array_flip($fields);
        $this->selectFields = array_keys($distinctFields);
    }
1128458
private function getComparisonField(array $item, string $field)
    {
        if (! isset($item[$field])) {
            throw new InvalidArgumentException(sprintf('Unable to find comparison field %s', $field));
        }

        $value = $item[$field];

        return is_string($value) ? strtolower($value) : $value;
    }
1278870
public function getField($field)
    {
        // If we already have a value in $this->record, then we should just return that
        if (isset($this->record[$field])) {
            return $this->record[$field];
        }

        // Do we have a field that needs to be lazy loaded?
        if (isset($this->record[$field . '_Lazy'])) {
            $tableClass = $this->record[$field . '_Lazy'];
            $this->loadLazyFields($tableClass);
        }
        $schema = static::getSchema();

        // Support unary relations as fields
        if ($schema->unaryComponent(static::class, $field)) {
            return $this->getComponent($field);
        }

        // In case of complex fields, return the DBField object
        if ($schema->compositeField(static::class, $field)) {
            $this->record[$field] = $this->dbObject($field);
        }

        return isset($this->record[$field]) ? $this->record[$field] : null;
    }
104097
public function append (Field $field)
    {
        if (in_array($field, $this->_fields, true)) {
            throw new InvalidArgumentException("{$this} already contains {$field}");
        }
        $this->_fields []= $field;
    }