Fit the guessing strategy to a set of values.

@param array $values
@throws \InvalidArgumentException
558227
public function fit(array $values) : void
    {
        if (empty($values)) {
            throw new InvalidArgumentException('Strategy must be fit with'
                . ' at least 1 value.');
        }

        $this->mean = Stats::mean($values);
    }
1254277
public function setRoles(array $roles)
    {
        $this->roleIdentifiers = [];
        $this->roles = [];
        foreach ($roles as $role) {
            if (!$role instanceof Role) {
                throw new \InvalidArgumentException(sprintf('setRoles() only accepts an array of %s instances, given: "%s"', Role::class, gettype($role)), 1397125997);
            }
            $this->addRole($role);
        }
    }
1210011
public function bindValues($values): void
    {
        $params = func_get_args();
        if (isset($params[0]) && is_array($params[0])) {
            $this->bindedValues = new \ArrayObject($params[0]);
        } else {
            $this->bindedValues = new \ArrayObject($params);
        }
    }
931876
protected function setValidation($values)
    {
        foreach ($values as $validation) {
            $value = isset($validation->value) ? $validation->value : true;

            $this->validation[$validation->rule] = $value;
        }
    }
647425
public static function in($values)
    {
        if ($values instanceof Arrayable) {
            $values = $values->toArray();
        }

        return new Rules\In(is_array($values) ? $values : func_get_args());
    }
541487
public function setResults(array $values)
    {
        foreach ($values as $field => $value) {
            if (empty($value)) {
                continue;
            }
            $this->setResult($field, $value);
        }

        return $this;
    }
970051
public static function range(array $values) : float
    {
        if (empty($values)) {
            throw new InvalidArgumentException('Range is undefined for empty'
                . ' set.');
        }

        return (float) (max($values) - min($values));
    }
1116658
public function setExpressions(array $expressions)
    {
        foreach ($expressions as $expression) {
            if (! $expression instanceof AbstractExpression) {
                throw new \InvalidArgumentException(
                    'Error: Expected array of AbstractExpression but got something else'
                );
            }
        }

        $this->expressions = $expressions;
    }
44595
public static function iqr(array $values) : float
    {
        $n = count($values);

        if ($n < 1) {
            throw new InvalidArgumentException('Interquartile range is not'
                . ' defined for empty set.');
        }

        $mid = intdiv($n, 2);

        sort($values);

        if ($n % 2 === 0) {
            $lower = array_slice($values, 0, $mid);
            $upper = array_slice($values, $mid);
        } else {
            $lower = array_slice($values, 0, $mid);
            $upper = array_slice($values, $mid + 1);
        }

        return self::median($upper) - self::median($lower);
    }
1217094
private function getDirection(array $values)
    {
        $direction = 'asc';

        if (array_key_exists(1, $values)) {
            $direction = $values[1];
        }

        switch (strtolower($direction)) {
            case 'asc':
                return Query::SORT_ASC;
            case 'desc':
                return Query::SORT_DESC;
        }

        throw new InvalidArgumentException(
            "Could not handle sort direction '{$direction}'"
        );
    }
1183006
protected function setValue($value)
    {
        if (!$this->validate($value)) {
            throw new \InvalidArgumentException(sprintf('%s is not a valid value', $value));
        }

        $this->value = $value;
    }
215881
public function setValues($values)
    {
        foreach ($this->findScenario() as $name) {
            if (array_key_exists($name, $values)) {
                $this->$name = $values[$name];
            }
        }
        return $this;
    }
298657
public function setValues(array $values)
    {
        $this->getValidator()->validateRequired($values, $this->required);
        $this->values = array_merge($this->values, $values);
        
        return $this;
    }
347533
public function in(array $values): bool
    {
        foreach ($values as $value) {
            if ($this->is($value)) {
                return true;
            }
        }

        return false;
    }
460105
public function values($values) {
		if (is_array($values))
			$this->value = $values;
		else
			$this->valueList = func_get_args();
		return $this;
	}
1102608
public static function median(array $values) : float
    {
        $n = count($values);

        if ($n < 1) {
            throw new InvalidArgumentException('Median is undefined for empty'
                . ' set.');
        }

        $mid = intdiv($n, 2);

        sort($values);

        if ($n % 2 === 1) {
            $median = $values[$mid];
        } else {
            $median = self::mean([$values[$mid - 1], $values[$mid]]);
        }

        return $median;
    }
1369711
public function put(array $values = [])
    {
        $this->qb->setQueryClass(PutItem::class);

        foreach ($values as $attributeName => $value) {
            $value = $this->value($value);

            if ($attributeName !== $this->qb->class->discriminatorAttribute) {
                $attribute     = $this->attr($attributeName);
                $mapping       = $attribute->getMapping();
                $attributeName = $mapping->attributeName;

                $value->setMapping($mapping);
            } else {
                $value->setMapping(null);
            }

            $this->put[$attributeName] = $value->getSerialized();
        }

        return $this->qb;
    }