id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
41,000 | datto/php-json-rpc-http | src/Client.php | Client.setHeader | public function setHeader($name, $value)
{
if (!self::isValidHeader($name, $value)) {
return false;
}
if (isset($this->requiredHttpHeaders[$name])) {
return $this->requiredHttpHeaders[$name] === $value;
}
$this->headers[$name] = $value;
return true;
} | php | public function setHeader($name, $value)
{
if (!self::isValidHeader($name, $value)) {
return false;
}
if (isset($this->requiredHttpHeaders[$name])) {
return $this->requiredHttpHeaders[$name] === $value;
}
$this->headers[$name] = $value;
return true;
} | [
"public",
"function",
"setHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"isValidHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this"... | Set add an additional HTTP header. This additional header will be sent
on each future HTTP request.
@param string $name
The name of the HTTP header (e.g. "Authorization").
@param string $value
The value of this HTTP header (e.g. "Basic YmFzaWM6YXV0aGVudGljYXRpb24=").
@return boolean
True iff the header has been set successfully (or has had the desired
value all along). Note that the CONTENT_TYPE, CONNECTION_TYPE, and
METHOD headers cannot be changed, because those headers are required. | [
"Set",
"add",
"an",
"additional",
"HTTP",
"header",
".",
"This",
"additional",
"header",
"will",
"be",
"sent",
"on",
"each",
"future",
"HTTP",
"request",
"."
] | 426aee88743f8c04b2b1b2ee30f89bd3a477ed18 | https://github.com/datto/php-json-rpc-http/blob/426aee88743f8c04b2b1b2ee30f89bd3a477ed18/src/Client.php#L254-L267 |
41,001 | datto/php-json-rpc-http | src/Client.php | Client.unsetHeader | public function unsetHeader($name)
{
if (!self::isValidHeaderName($name)) {
return true;
}
if (isset($this->requiredHttpHeaders[$name])) {
return false;
}
unset($this->headers[$name]);
return true;
} | php | public function unsetHeader($name)
{
if (!self::isValidHeaderName($name)) {
return true;
}
if (isset($this->requiredHttpHeaders[$name])) {
return false;
}
unset($this->headers[$name]);
return true;
} | [
"public",
"function",
"unsetHeader",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"isValidHeaderName",
"(",
"$",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"requiredHttpHeaders",
"[",
"... | Unset an existing HTTP header. This HTTP header will no longer be sent
on future requests.
@param string $name
The name of the HTTP header (e.g. "Authorization").
@return boolean
True iff the header was successfully removed (or was never set in the
first place). Note that the CONTENT_TYPE, CONNECTION_TYPE, and METHOD
headers are required, so those headers cannot be unset. | [
"Unset",
"an",
"existing",
"HTTP",
"header",
".",
"This",
"HTTP",
"header",
"will",
"no",
"longer",
"be",
"sent",
"on",
"future",
"requests",
"."
] | 426aee88743f8c04b2b1b2ee30f89bd3a477ed18 | https://github.com/datto/php-json-rpc-http/blob/426aee88743f8c04b2b1b2ee30f89bd3a477ed18/src/Client.php#L281-L293 |
41,002 | jedrzej/searchable | src/Jedrzej/Searchable/SearchableTrait.php | SearchableTrait.getConstraints | protected function getConstraints(Builder $builder, array $query)
{
$constraints = [];
foreach ($query as $field => $values) {
if ($this->isFieldSearchable($builder, $field)) {
$constraints[$field] = $this->buildConstraints($values);
}
}
return $constraints;
} | php | protected function getConstraints(Builder $builder, array $query)
{
$constraints = [];
foreach ($query as $field => $values) {
if ($this->isFieldSearchable($builder, $field)) {
$constraints[$field] = $this->buildConstraints($values);
}
}
return $constraints;
} | [
"protected",
"function",
"getConstraints",
"(",
"Builder",
"$",
"builder",
",",
"array",
"$",
"query",
")",
"{",
"$",
"constraints",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"query",
"as",
"$",
"field",
"=>",
"$",
"values",
")",
"{",
"if",
"(",
"$",
... | Builds search constraints based on model's searchable fields and query parameters.
@param Builder $builder query builder
@param array $query query parameters
@return array | [
"Builds",
"search",
"constraints",
"based",
"on",
"model",
"s",
"searchable",
"fields",
"and",
"query",
"parameters",
"."
] | 1f7912406172f9f210c906d401134cb33215a0d0 | https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/SearchableTrait.php#L42-L52 |
41,003 | jedrzej/searchable | src/Jedrzej/Searchable/SearchableTrait.php | SearchableTrait.validateFieldNames | protected function validateFieldNames(array $query) {
foreach ($query as $field => $values) {
if (!preg_match('/^!?[a-zA-Z0-9\-_:]+$/', $field)) {
throw new InvalidArgumentException(sprintf('Incorrect field name: %s', $field));
}
}
} | php | protected function validateFieldNames(array $query) {
foreach ($query as $field => $values) {
if (!preg_match('/^!?[a-zA-Z0-9\-_:]+$/', $field)) {
throw new InvalidArgumentException(sprintf('Incorrect field name: %s', $field));
}
}
} | [
"protected",
"function",
"validateFieldNames",
"(",
"array",
"$",
"query",
")",
"{",
"foreach",
"(",
"$",
"query",
"as",
"$",
"field",
"=>",
"$",
"values",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^!?[a-zA-Z0-9\\-_:]+$/'",
",",
"$",
"field",
")",
... | Makes sure field names contain only allowed characters
@param array $query | [
"Makes",
"sure",
"field",
"names",
"contain",
"only",
"allowed",
"characters"
] | 1f7912406172f9f210c906d401134cb33215a0d0 | https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/SearchableTrait.php#L59-L65 |
41,004 | jedrzej/searchable | src/Jedrzej/Searchable/SearchableTrait.php | SearchableTrait.isFieldSearchable | protected function isFieldSearchable(Builder $builder, $field)
{
$searchable = $this->_getSearchableAttributes($builder);
$notSearchable = $this->_getNotSearchableAttributes($builder);
$field = preg_replace('#^!#', '', $field);
return !in_array($field, $notSearchable) && !in_array('*', $notSearchable) && (in_array($field, $searchable) || in_array('*', $searchable));
} | php | protected function isFieldSearchable(Builder $builder, $field)
{
$searchable = $this->_getSearchableAttributes($builder);
$notSearchable = $this->_getNotSearchableAttributes($builder);
$field = preg_replace('#^!#', '', $field);
return !in_array($field, $notSearchable) && !in_array('*', $notSearchable) && (in_array($field, $searchable) || in_array('*', $searchable));
} | [
"protected",
"function",
"isFieldSearchable",
"(",
"Builder",
"$",
"builder",
",",
"$",
"field",
")",
"{",
"$",
"searchable",
"=",
"$",
"this",
"->",
"_getSearchableAttributes",
"(",
"$",
"builder",
")",
";",
"$",
"notSearchable",
"=",
"$",
"this",
"->",
"... | Check if field is searchable for given model.
@param Builder $builder query builder
@param string $field field name
@return bool | [
"Check",
"if",
"field",
"is",
"searchable",
"for",
"given",
"model",
"."
] | 1f7912406172f9f210c906d401134cb33215a0d0 | https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/SearchableTrait.php#L75-L83 |
41,005 | jedrzej/searchable | src/Jedrzej/Searchable/SearchableTrait.php | SearchableTrait.applyConstraints | protected function applyConstraints(Builder $builder, array $constraints, $mode = Constraint::MODE_AND)
{
foreach ($constraints as $field => $constraint) {
if (is_array($constraint)) {
foreach ($constraint as $single_constraint) {
$this->applyConstraint($builder, $field, $single_constraint, $mode);
}
} else {
$this->applyConstraint($builder, $field, $constraint, $mode);
}
}
} | php | protected function applyConstraints(Builder $builder, array $constraints, $mode = Constraint::MODE_AND)
{
foreach ($constraints as $field => $constraint) {
if (is_array($constraint)) {
foreach ($constraint as $single_constraint) {
$this->applyConstraint($builder, $field, $single_constraint, $mode);
}
} else {
$this->applyConstraint($builder, $field, $constraint, $mode);
}
}
} | [
"protected",
"function",
"applyConstraints",
"(",
"Builder",
"$",
"builder",
",",
"array",
"$",
"constraints",
",",
"$",
"mode",
"=",
"Constraint",
"::",
"MODE_AND",
")",
"{",
"foreach",
"(",
"$",
"constraints",
"as",
"$",
"field",
"=>",
"$",
"constraint",
... | Applies constraints to query, allowing model to overwrite any of them.
@param Builder $builder query builder
@param Constraint[] $constraints constraints
@param string $mode determines how constraints are applied ("or" or "and") | [
"Applies",
"constraints",
"to",
"query",
"allowing",
"model",
"to",
"overwrite",
"any",
"of",
"them",
"."
] | 1f7912406172f9f210c906d401134cb33215a0d0 | https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/SearchableTrait.php#L92-L103 |
41,006 | jedrzej/searchable | src/Jedrzej/Searchable/SearchableTrait.php | SearchableTrait.callInterceptor | protected function callInterceptor(Builder $builder, $field, Constraint $constraint)
{
$model = $builder->getModel();
$interceptor = sprintf('process%sFilter', str_replace(':', '_', Str::studly($field)));
if (method_exists($model, $interceptor)) {
if ($model->$interceptor($builder, $constraint)) {
return true;
}
}
return false;
} | php | protected function callInterceptor(Builder $builder, $field, Constraint $constraint)
{
$model = $builder->getModel();
$interceptor = sprintf('process%sFilter', str_replace(':', '_', Str::studly($field)));
if (method_exists($model, $interceptor)) {
if ($model->$interceptor($builder, $constraint)) {
return true;
}
}
return false;
} | [
"protected",
"function",
"callInterceptor",
"(",
"Builder",
"$",
"builder",
",",
"$",
"field",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"$",
"model",
"=",
"$",
"builder",
"->",
"getModel",
"(",
")",
";",
"$",
"interceptor",
"=",
"sprintf",
"(",
"'... | Calls constraint interceptor on model.
@param Builder $builder query builder
@param string $field field on which constraint is applied
@param Constraint $constraint constraint
@return bool true if constraint was intercepted by model's method | [
"Calls",
"constraint",
"interceptor",
"on",
"model",
"."
] | 1f7912406172f9f210c906d401134cb33215a0d0 | https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/SearchableTrait.php#L114-L126 |
41,007 | jedrzej/searchable | src/Jedrzej/Searchable/SearchableTrait.php | SearchableTrait.buildConstraints | protected function buildConstraints($values)
{
if (is_array($values)) {
$constraints = [];
foreach ($values as $value) {
$constraints[] = Constraint::make($value);
}
return $constraints;
} else {
return Constraint::make($values);
}
} | php | protected function buildConstraints($values)
{
if (is_array($values)) {
$constraints = [];
foreach ($values as $value) {
$constraints[] = Constraint::make($value);
}
return $constraints;
} else {
return Constraint::make($values);
}
} | [
"protected",
"function",
"buildConstraints",
"(",
"$",
"values",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"$",
"constraints",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"constraint... | Build Constraint objects from given filter values
@param string []|string
@return Constraint[]|Constraint | [
"Build",
"Constraint",
"objects",
"from",
"given",
"filter",
"values"
] | 1f7912406172f9f210c906d401134cb33215a0d0 | https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/SearchableTrait.php#L135-L146 |
41,008 | jedrzej/searchable | src/Jedrzej/Searchable/SearchableTrait.php | SearchableTrait.applyConstraint | protected function applyConstraint(Builder $builder, $field, $constraint, $mode = Constraint::MODE_AND)
{
// let model handle the constraint if it has the interceptor
if (!$this->callInterceptor($builder, $field, $constraint)) {
$constraint->apply($builder, $field, $mode);
}
} | php | protected function applyConstraint(Builder $builder, $field, $constraint, $mode = Constraint::MODE_AND)
{
// let model handle the constraint if it has the interceptor
if (!$this->callInterceptor($builder, $field, $constraint)) {
$constraint->apply($builder, $field, $mode);
}
} | [
"protected",
"function",
"applyConstraint",
"(",
"Builder",
"$",
"builder",
",",
"$",
"field",
",",
"$",
"constraint",
",",
"$",
"mode",
"=",
"Constraint",
"::",
"MODE_AND",
")",
"{",
"// let model handle the constraint if it has the interceptor",
"if",
"(",
"!",
... | Apply a single constraint - either directly or using model's interceptor
@param Builder $builder query builder
@param string $field field name
@param Constraint $constraint constraint
@param string $mode determines how constraint is applied ("or" or "and") | [
"Apply",
"a",
"single",
"constraint",
"-",
"either",
"directly",
"or",
"using",
"model",
"s",
"interceptor"
] | 1f7912406172f9f210c906d401134cb33215a0d0 | https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/SearchableTrait.php#L156-L162 |
41,009 | jedrzej/searchable | src/Jedrzej/Searchable/Constraint.php | Constraint.make | public static function make($value)
{
$value = static::prepareValue($value);
$is_negation = static::parseIsNegation($value);
list($operator, $value) = static::parseOperatorAndValue($value, $is_negation);
return new static($operator, $value, $is_negation);
} | php | public static function make($value)
{
$value = static::prepareValue($value);
$is_negation = static::parseIsNegation($value);
list($operator, $value) = static::parseOperatorAndValue($value, $is_negation);
return new static($operator, $value, $is_negation);
} | [
"public",
"static",
"function",
"make",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"static",
"::",
"prepareValue",
"(",
"$",
"value",
")",
";",
"$",
"is_negation",
"=",
"static",
"::",
"parseIsNegation",
"(",
"$",
"value",
")",
";",
"list",
"(",
... | Creates constraint object for given filter.
@param string $value query value
@return Constraint | [
"Creates",
"constraint",
"object",
"for",
"given",
"filter",
"."
] | 1f7912406172f9f210c906d401134cb33215a0d0 | https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/Constraint.php#L66-L73 |
41,010 | jedrzej/searchable | src/Jedrzej/Searchable/Constraint.php | Constraint.apply | public function apply(Builder $builder, $field, $mode = Constraint::MODE_AND)
{
if ($this->isRelation($field)) {
list($relation, $field) = $this->splitRelationField($field);
if (static::parseIsNegation($relation)) {
$builder->whereDoesntHave($relation, function (Builder $builder) use ($field, $mode) {
$this->doApply($builder, $field, $mode);
});
} else {
$builder->whereHas($relation, function (Builder $builder) use ($field, $mode) {
$this->doApply($builder, $field, $mode);
});
}
} else {
$this->doApply($builder, $field, $mode);
}
} | php | public function apply(Builder $builder, $field, $mode = Constraint::MODE_AND)
{
if ($this->isRelation($field)) {
list($relation, $field) = $this->splitRelationField($field);
if (static::parseIsNegation($relation)) {
$builder->whereDoesntHave($relation, function (Builder $builder) use ($field, $mode) {
$this->doApply($builder, $field, $mode);
});
} else {
$builder->whereHas($relation, function (Builder $builder) use ($field, $mode) {
$this->doApply($builder, $field, $mode);
});
}
} else {
$this->doApply($builder, $field, $mode);
}
} | [
"public",
"function",
"apply",
"(",
"Builder",
"$",
"builder",
",",
"$",
"field",
",",
"$",
"mode",
"=",
"Constraint",
"::",
"MODE_AND",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isRelation",
"(",
"$",
"field",
")",
")",
"{",
"list",
"(",
"$",
"rela... | Applies constraint to query.
@param Builder $builder query builder
@param string $field field name
@param string $mode determines how constraint is added to existing query ("or" or "and") | [
"Applies",
"constraint",
"to",
"query",
"."
] | 1f7912406172f9f210c906d401134cb33215a0d0 | https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/Constraint.php#L82-L98 |
41,011 | jedrzej/searchable | src/Jedrzej/Searchable/Constraint.php | Constraint.splitRelationField | protected function splitRelationField($field)
{
$parts = explode(':', $field);
$partsCount = count($parts);
return [implode('.', array_slice($parts, 0, $partsCount - 1)), $parts[$partsCount - 1]];
} | php | protected function splitRelationField($field)
{
$parts = explode(':', $field);
$partsCount = count($parts);
return [implode('.', array_slice($parts, 0, $partsCount - 1)), $parts[$partsCount - 1]];
} | [
"protected",
"function",
"splitRelationField",
"(",
"$",
"field",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"':'",
",",
"$",
"field",
")",
";",
"$",
"partsCount",
"=",
"count",
"(",
"$",
"parts",
")",
";",
"return",
"[",
"implode",
"(",
"'.'",
","... | Splits given field name containing relation name into relation name and field name
@param string $field field name
@return array relation name at index 0, field name at index 1 | [
"Splits",
"given",
"field",
"name",
"containing",
"relation",
"name",
"into",
"relation",
"name",
"and",
"field",
"name"
] | 1f7912406172f9f210c906d401134cb33215a0d0 | https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/Constraint.php#L116-L122 |
41,012 | jedrzej/searchable | src/Jedrzej/Searchable/Constraint.php | Constraint.doApply | protected function doApply(Builder $builder, $field, $mode = Constraint::MODE_AND)
{
if ($this->operator == Constraint::OPERATOR_IN) {
$method = $mode != static::MODE_OR ? 'whereIn' : 'orWhereIn';
$builder->$method($field, $this->value);
} elseif ($this->operator == Constraint::OPERATOR_NOT_IN) {
$method = $mode != static::MODE_OR ? 'whereNotIn' : 'orWhereNotIn';
$builder->$method($field, $this->value);
} elseif ($this->operator == Constraint::OPERATOR_NOT_NULL) {
$method = $mode != static::MODE_OR ? 'whereNotNull' : 'orWhereNotNull';
$builder->$method($field);
} elseif ($this->operator == Constraint::OPERATOR_NULL) {
$method = $mode != static::MODE_OR ? 'whereNull' : 'orWhereNull';
$builder->$method($field);
} else {
$method = $mode != static::MODE_OR ? 'where' : 'orWhere';
$builder->$method($field, $this->operator, $this->value);
}
} | php | protected function doApply(Builder $builder, $field, $mode = Constraint::MODE_AND)
{
if ($this->operator == Constraint::OPERATOR_IN) {
$method = $mode != static::MODE_OR ? 'whereIn' : 'orWhereIn';
$builder->$method($field, $this->value);
} elseif ($this->operator == Constraint::OPERATOR_NOT_IN) {
$method = $mode != static::MODE_OR ? 'whereNotIn' : 'orWhereNotIn';
$builder->$method($field, $this->value);
} elseif ($this->operator == Constraint::OPERATOR_NOT_NULL) {
$method = $mode != static::MODE_OR ? 'whereNotNull' : 'orWhereNotNull';
$builder->$method($field);
} elseif ($this->operator == Constraint::OPERATOR_NULL) {
$method = $mode != static::MODE_OR ? 'whereNull' : 'orWhereNull';
$builder->$method($field);
} else {
$method = $mode != static::MODE_OR ? 'where' : 'orWhere';
$builder->$method($field, $this->operator, $this->value);
}
} | [
"protected",
"function",
"doApply",
"(",
"Builder",
"$",
"builder",
",",
"$",
"field",
",",
"$",
"mode",
"=",
"Constraint",
"::",
"MODE_AND",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"operator",
"==",
"Constraint",
"::",
"OPERATOR_IN",
")",
"{",
"$",
"m... | Applies non-relation constraint to query.
@param Builder $builder query builder
@param string $field field name
@param string $mode determines how constraint is added to existing query ("or" or "and") | [
"Applies",
"non",
"-",
"relation",
"constraint",
"to",
"query",
"."
] | 1f7912406172f9f210c906d401134cb33215a0d0 | https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/Constraint.php#L131-L149 |
41,013 | jedrzej/searchable | src/Jedrzej/Searchable/Constraint.php | Constraint.parseOperatorAndValue | protected static function parseOperatorAndValue($value, $is_negation)
{
if ($result = static::parseComparisonOperator($value, $is_negation)) {
return $result;
}
if ($result = static::parseLikeOperator($value, $is_negation)) {
return $result;
}
if ($result = static::parseNullOperator($value, $is_negation)) {
return $result;
}
if ($result = static::parseEqualsInOperator($value, $is_negation)) {
return $result;
}
throw new InvalidArgumentException(sprintf('Unable to parse operator or value from "%s"', $value));
} | php | protected static function parseOperatorAndValue($value, $is_negation)
{
if ($result = static::parseComparisonOperator($value, $is_negation)) {
return $result;
}
if ($result = static::parseLikeOperator($value, $is_negation)) {
return $result;
}
if ($result = static::parseNullOperator($value, $is_negation)) {
return $result;
}
if ($result = static::parseEqualsInOperator($value, $is_negation)) {
return $result;
}
throw new InvalidArgumentException(sprintf('Unable to parse operator or value from "%s"', $value));
} | [
"protected",
"static",
"function",
"parseOperatorAndValue",
"(",
"$",
"value",
",",
"$",
"is_negation",
")",
"{",
"if",
"(",
"$",
"result",
"=",
"static",
"::",
"parseComparisonOperator",
"(",
"$",
"value",
",",
"$",
"is_negation",
")",
")",
"{",
"return",
... | Parse query parameter and get operator and value.
@param string $value
@param bool $is_negation
@return string[]
@throws InvalidArgumentException when unable to parse operator or value | [
"Parse",
"query",
"parameter",
"and",
"get",
"operator",
"and",
"value",
"."
] | 1f7912406172f9f210c906d401134cb33215a0d0 | https://github.com/jedrzej/searchable/blob/1f7912406172f9f210c906d401134cb33215a0d0/src/Jedrzej/Searchable/Constraint.php#L203-L222 |
41,014 | filestack/filestack-php | filestack/Filelink.php | Filelink.ascii | public function ascii($background = 'white', $colored = false,
$foreground='red', $reverse = false, $size = 100)
{
$options = [
'b' => $background,
'c' => $colored ? 'true' : 'false',
'f' => $foreground,
'r' => $reverse ? 'true' : 'false',
's' => $size
];
// call TransformationMixin function
$this->setTransformUrl('ascii', $options);
return $this;
} | php | public function ascii($background = 'white', $colored = false,
$foreground='red', $reverse = false, $size = 100)
{
$options = [
'b' => $background,
'c' => $colored ? 'true' : 'false',
'f' => $foreground,
'r' => $reverse ? 'true' : 'false',
's' => $size
];
// call TransformationMixin function
$this->setTransformUrl('ascii', $options);
return $this;
} | [
"public",
"function",
"ascii",
"(",
"$",
"background",
"=",
"'white'",
",",
"$",
"colored",
"=",
"false",
",",
"$",
"foreground",
"=",
"'red'",
",",
"$",
"reverse",
"=",
"false",
",",
"$",
"size",
"=",
"100",
")",
"{",
"$",
"options",
"=",
"[",
"'b... | Set this Filelink's transform_url to include ascii task
@param string $background background color of the HTML file. This
can be the word for a color hex value
e.g. ('black' or '000000')
@param bool $colored Reproduces the colors in the original image
if set to true.
@param string $foreground Specifies the font color of ASCII images.
Only works in non-colored mode.
@param bool $reverse Reverses the character set used to generate
the ASCII output. Requires colored:true.
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Set",
"this",
"Filelink",
"s",
"transform_url",
"to",
"include",
"ascii",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L70-L85 |
41,015 | filestack/filestack-php | filestack/Filelink.php | Filelink.border | public function border($background = 'white', $color = 'black', $width=2)
{
$options = [
'b' => $background,
'c' => $color,
'w' => $width
];
// call TransformationMixin function
$this->setTransformUrl('border', $options);
return $this;
} | php | public function border($background = 'white', $color = 'black', $width=2)
{
$options = [
'b' => $background,
'c' => $color,
'w' => $width
];
// call TransformationMixin function
$this->setTransformUrl('border', $options);
return $this;
} | [
"public",
"function",
"border",
"(",
"$",
"background",
"=",
"'white'",
",",
"$",
"color",
"=",
"'black'",
",",
"$",
"width",
"=",
"2",
")",
"{",
"$",
"options",
"=",
"[",
"'b'",
"=>",
"$",
"background",
",",
"'c'",
"=>",
"$",
"color",
",",
"'w'",
... | Set this Filelink's transform_url to include border task
@param string $background Sets the background color to display behind
the image. This can be the word for a color,
or the hex color code, e.g. ('red' or 'FF0000')
@param string $color Sets the color of the border to render around
the image. This can be the word for a color,
or the hex color code, e.g. ('red' or 'FF0000')
@param int $width Sets the width in pixels of the border to render
around the image. The value for this parameter
must be in a range from 1 to 1000.
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Set",
"this",
"Filelink",
"s",
"transform_url",
"to",
"include",
"border",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L142-L154 |
41,016 | filestack/filestack-php | filestack/Filelink.php | Filelink.modulate | public function modulate($brightness = 100, $hue = 0, $saturation = 100)
{
$options = [
'b' => $brightness,
'h' => $hue,
's' => $saturation
];
// call TransformationMixin function
$this->setTransformUrl('modulate', $options);
return $this;
} | php | public function modulate($brightness = 100, $hue = 0, $saturation = 100)
{
$options = [
'b' => $brightness,
'h' => $hue,
's' => $saturation
];
// call TransformationMixin function
$this->setTransformUrl('modulate', $options);
return $this;
} | [
"public",
"function",
"modulate",
"(",
"$",
"brightness",
"=",
"100",
",",
"$",
"hue",
"=",
"0",
",",
"$",
"saturation",
"=",
"100",
")",
"{",
"$",
"options",
"=",
"[",
"'b'",
"=>",
"$",
"brightness",
",",
"'h'",
"=>",
"$",
"hue",
",",
"'s'",
"=>... | Set this Filelink's transform_url to include the modulate task
@param int $brightness The amount to change the brightness of an
image. The value range is 0 to 10000.
@param int $hue The degree to set the hue to. The value
range is 0 - 359, where 0 is the equivalent
of red and 180 is the equivalent of cyan.
@param int $saturation The amount to change the saturation of image.
The value range is 0 to 10000.
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Set",
"this",
"Filelink",
"s",
"transform_url",
"to",
"include",
"the",
"modulate",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L625-L637 |
41,017 | filestack/filestack-php | filestack/Filelink.php | Filelink.partialBlur | public function partialBlur($amount = 10, $blur = 4, $objects = [], $type = 'rect')
{
$options = [
'a' => $amount,
'l' => $blur,
'o' => $objects,
't' => $type
];
// call TransformationMixin function
$this->setTransformUrl('partial_blur', $options);
return $this;
} | php | public function partialBlur($amount = 10, $blur = 4, $objects = [], $type = 'rect')
{
$options = [
'a' => $amount,
'l' => $blur,
'o' => $objects,
't' => $type
];
// call TransformationMixin function
$this->setTransformUrl('partial_blur', $options);
return $this;
} | [
"public",
"function",
"partialBlur",
"(",
"$",
"amount",
"=",
"10",
",",
"$",
"blur",
"=",
"4",
",",
"$",
"objects",
"=",
"[",
"]",
",",
"$",
"type",
"=",
"'rect'",
")",
"{",
"$",
"options",
"=",
"[",
"'a'",
"=>",
"$",
"amount",
",",
"'l'",
"=>... | Set this Filelink's transform_url to include the partial_blur task
@param int $amount The amount to blur the image. Range is 1 to 20
@param int $blur The amount to blur the image. Range is 0 to 20.
@param array $objects The area(s) of the image to blur. This variable
is an array of arrays. Each array input for
this parameter defines a different section of
the image and must have exactly 4 integers:
'x coordinate,y coordinate,width,height' - e.g.
[[10,20,200,250]] selects a 200x250px rectangle
starting 10 pixels from the left edge of the
image and 20 pixels from the top edge of the
image. The values for these arrays can be any
integer from 0 to 10000.
@param string $type The shape of the blur area. The options are rect
(for a rectangle shape) or oval (for an oval shape).
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Set",
"this",
"Filelink",
"s",
"transform_url",
"to",
"include",
"the",
"partial_blur",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L709-L722 |
41,018 | filestack/filestack-php | filestack/Filelink.php | Filelink.partialPixelate | public function partialPixelate($amount = 10, $blur = 4, $objects = [], $type = 'rect')
{
// call TransformationMixin function
$this->setTransformUrl('partial_pixelate', ['a' => $amount,
'l' => $blur, 'o' => $objects, 't' => $type]);
return $this;
} | php | public function partialPixelate($amount = 10, $blur = 4, $objects = [], $type = 'rect')
{
// call TransformationMixin function
$this->setTransformUrl('partial_pixelate', ['a' => $amount,
'l' => $blur, 'o' => $objects, 't' => $type]);
return $this;
} | [
"public",
"function",
"partialPixelate",
"(",
"$",
"amount",
"=",
"10",
",",
"$",
"blur",
"=",
"4",
",",
"$",
"objects",
"=",
"[",
"]",
",",
"$",
"type",
"=",
"'rect'",
")",
"{",
"// call TransformationMixin function",
"$",
"this",
"->",
"setTransformUrl",... | Set this Filelink's transform_url to include the partial_pixelate task
@param int $amount Amount to pixelate the image. Range is 2 to 100
@param int $blur Amount to pixelate the image. Range is 0 to 20.
@param array $objects Area(s) of the image to blur. This variable
is an array of arrays. Each array input for
this parameter defines a different section of
the image and must have exactly 4 integers:
'x coordinate,y coordinate,width,height' - e.g.
[[10,20,200,250]] selects a 200x250px rectangle
starting 10 pixels from the left edge of the
image and 20 pixels from the top edge of the
image. The values for these arrays can be any
integer from 0 to 10000.
@param string $type The shape of the blur area. The options are rect
(for rectangle shape) or oval (for oval shape).
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Set",
"this",
"Filelink",
"s",
"transform_url",
"to",
"include",
"the",
"partial_pixelate",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L746-L754 |
41,019 | filestack/filestack-php | filestack/Filelink.php | Filelink.polaroid | public function polaroid($background = 'white', $color = 'snow', $rotate = 45)
{
$options = [
'b' => $background,
'c' => $color,
'r' => $rotate
];
// call TransformationMixin function
$this->setTransformUrl('polaroid', $options);
return $this;
} | php | public function polaroid($background = 'white', $color = 'snow', $rotate = 45)
{
$options = [
'b' => $background,
'c' => $color,
'r' => $rotate
];
// call TransformationMixin function
$this->setTransformUrl('polaroid', $options);
return $this;
} | [
"public",
"function",
"polaroid",
"(",
"$",
"background",
"=",
"'white'",
",",
"$",
"color",
"=",
"'snow'",
",",
"$",
"rotate",
"=",
"45",
")",
"{",
"$",
"options",
"=",
"[",
"'b'",
"=>",
"$",
"background",
",",
"'c'",
"=>",
"$",
"color",
",",
"'r'... | Set this Filelink's transform_url to include the polaroid task
@param string $background Sets the background color to display behind
the image. This can be the word for a color,
or the hex color code, ('red' or 'FF0000')
@param string $color Sets the polaroid frame color. This can be
a word or the hex value ('red' or 'FF0000')
@param int $rotate Degree by which to rotate the image clockwise.
Range is 0 to 359.
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Set",
"this",
"Filelink",
"s",
"transform_url",
"to",
"include",
"the",
"polaroid",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L788-L800 |
41,020 | filestack/filestack-php | filestack/Filelink.php | Filelink.resize | public function resize($width, $height, $fit = 'clip', $align = 'center')
{
$options = [
'w' => $width,
'h' => $height,
'f' => $fit,
'a' => $align
];
// call TransformationMixin function
$this->setTransformUrl('resize', $options);
return $this;
} | php | public function resize($width, $height, $fit = 'clip', $align = 'center')
{
$options = [
'w' => $width,
'h' => $height,
'f' => $fit,
'a' => $align
];
// call TransformationMixin function
$this->setTransformUrl('resize', $options);
return $this;
} | [
"public",
"function",
"resize",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"fit",
"=",
"'clip'",
",",
"$",
"align",
"=",
"'center'",
")",
"{",
"$",
"options",
"=",
"[",
"'w'",
"=>",
"$",
"width",
",",
"'h'",
"=>",
"$",
"height",
",",
"'f'",... | Set this Filelink's transform_url to include the resize task
@param int $width The width in pixels to resize the image to.
The range is 1 to 10000.
@param int $height The height in pixels to resize the image to.
The range is 1 to 10000.
@param string $fit clip, crop, scale, or max
'clip': Resizes the image to fit within the
specified parameters without distorting,
cropping, or changing the aspect ratio.
'crop': Resizes the image to fit the specified
parameters exactly by removing any parts of
the image that don't fit within the boundaries.
'scale': Resizes the image to fit the specified
parameters exactly by scaling the image to
the desired size. The aspect ratio of the
image is not respected and the image can
be distorted using this method.
'max': Resizes the image to fit within the
parameters, but as opposed to 'clip' will
not scale the image if the image is smaller
than the output size.
@param string $align Using align, you can choose the area of the image
to focus on. Possible values:
center, top, bottom, left, right, or faces
You can also specify pairs e.g. align:[top,left].
Center cannot be used in pairs.
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Set",
"this",
"Filelink",
"s",
"transform_url",
"to",
"include",
"the",
"resize",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L875-L888 |
41,021 | filestack/filestack-php | filestack/Filelink.php | Filelink.roundedCorners | public function roundedCorners($background = 'white', $blur = 0.3, $radius = 10)
{
$options = [
'b' => $background,
'l' => $blur,
'r' => $radius
];
// call TransformationMixin function
$this->setTransformUrl('rounded_corners', $options);
return $this;
} | php | public function roundedCorners($background = 'white', $blur = 0.3, $radius = 10)
{
$options = [
'b' => $background,
'l' => $blur,
'r' => $radius
];
// call TransformationMixin function
$this->setTransformUrl('rounded_corners', $options);
return $this;
} | [
"public",
"function",
"roundedCorners",
"(",
"$",
"background",
"=",
"'white'",
",",
"$",
"blur",
"=",
"0.3",
",",
"$",
"radius",
"=",
"10",
")",
"{",
"$",
"options",
"=",
"[",
"'b'",
"=>",
"$",
"background",
",",
"'l'",
"=>",
"$",
"blur",
",",
"'r... | Set this Filelink's transform_url to include the rounded_corners task
@param string $background Sets the background color to display behind
the image. This can be the word for a color,
or the hex color code, e.g. ('red' or 'FF0000')
@param float $blur Specify the amount of blur to apply to the
rounded edges of the image. (0 - 20).
@param int $radius The radius of the rounded corner effect on
the image. (0-10000)
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Set",
"this",
"Filelink",
"s",
"transform_url",
"to",
"include",
"the",
"rounded_corners",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L905-L917 |
41,022 | filestack/filestack-php | filestack/Filelink.php | Filelink.rotate | public function rotate($background = 'white', $deg = 0, $exif = false)
{
$options = [
'b' => $background,
'd' => $deg,
'e' => $exif ? 'true' : 'false'
];
// call TransformationMixin function
$this->setTransformUrl('rotate', $options);
return $this;
} | php | public function rotate($background = 'white', $deg = 0, $exif = false)
{
$options = [
'b' => $background,
'd' => $deg,
'e' => $exif ? 'true' : 'false'
];
// call TransformationMixin function
$this->setTransformUrl('rotate', $options);
return $this;
} | [
"public",
"function",
"rotate",
"(",
"$",
"background",
"=",
"'white'",
",",
"$",
"deg",
"=",
"0",
",",
"$",
"exif",
"=",
"false",
")",
"{",
"$",
"options",
"=",
"[",
"'b'",
"=>",
"$",
"background",
",",
"'d'",
"=>",
"$",
"deg",
",",
"'e'",
"=>",... | Set this Filelink's transform_url to include the rotate task
@param string $background Sets the background color to display behind
the image. This can be the word for a color,
or the hex color code, e.g. ('red' or 'FF0000')
@param int $deg The degree by which to rotate the image
clockwise (0 to 359). Alternatively, you can
set the degree to 'exif' and the image will
be rotated based upon any exif metadata it
may contain.
@param bool $exif Sets the EXIF orientation of the image to
EXIF orientation 1. The exif=false parameter
takes an image and sets the exif orientation
to the first of the eight EXIF orientations.
The image will behave as though it is contained
in an html img tag if displayed in application
that supports EXIF orientations.
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Set",
"this",
"Filelink",
"s",
"transform_url",
"to",
"include",
"the",
"rotate",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L942-L954 |
41,023 | filestack/filestack-php | filestack/Filelink.php | Filelink.shadow | public function shadow($background = 'white', $blur = 4,
$opacity = 60, $vector = [4,4])
{
$options = [
'b' => $background,
'l' => $blur,
'o' => $opacity,
'v' => $vector
];
// call TransformationMixin function
$this->setTransformUrl('shadow', $options);
return $this;
} | php | public function shadow($background = 'white', $blur = 4,
$opacity = 60, $vector = [4,4])
{
$options = [
'b' => $background,
'l' => $blur,
'o' => $opacity,
'v' => $vector
];
// call TransformationMixin function
$this->setTransformUrl('shadow', $options);
return $this;
} | [
"public",
"function",
"shadow",
"(",
"$",
"background",
"=",
"'white'",
",",
"$",
"blur",
"=",
"4",
",",
"$",
"opacity",
"=",
"60",
",",
"$",
"vector",
"=",
"[",
"4",
",",
"4",
"]",
")",
"{",
"$",
"options",
"=",
"[",
"'b'",
"=>",
"$",
"backgro... | Set this Filelink's transform_url to include the shadow task
@param string $background Sets the background color to display behind
the image. This can be the word for a color,
or the hex color code, e.g. ('red' or 'FF0000')
@param int $blur Sets the level of blur for the shadow effect.
Value range is 0 to 20.
@param int $opacity Sets the opacity level of the shadow effect.
Value range is 0 to 100.
@param array $vector Sets the vector of the shadow effect. The
value must be an array of two integers in a
range from -1000 to 1000. These are the
X and Y parameters that determine the position
of the shadow.
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Set",
"this",
"Filelink",
"s",
"transform_url",
"to",
"include",
"the",
"shadow",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1012-L1026 |
41,024 | filestack/filestack-php | filestack/Filelink.php | Filelink.tornEdges | public function tornEdges($background = 'white', $spread = [1,10])
{
$options = [
'b' => $background,
's' => $spread
];
// call TransformationMixin function
$this->setTransformUrl('torn_edges', $options);
return $this;
} | php | public function tornEdges($background = 'white', $spread = [1,10])
{
$options = [
'b' => $background,
's' => $spread
];
// call TransformationMixin function
$this->setTransformUrl('torn_edges', $options);
return $this;
} | [
"public",
"function",
"tornEdges",
"(",
"$",
"background",
"=",
"'white'",
",",
"$",
"spread",
"=",
"[",
"1",
",",
"10",
"]",
")",
"{",
"$",
"options",
"=",
"[",
"'b'",
"=>",
"$",
"background",
",",
"'s'",
"=>",
"$",
"spread",
"]",
";",
"// call Tr... | Set this Filelink's transform_url to include the torn_edges task
@param string $background Sets the background color to display behind
the image. This can be the word for a color,
or the hex color code, e.g. ('red' or 'FF0000')
@param array $spread Sets the spread of the tearing effect. The
value must be an array of two integers in
a range from 1 to 10000.
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Set",
"this",
"Filelink",
"s",
"transform_url",
"to",
"include",
"the",
"torn_edges",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1042-L1053 |
41,025 | filestack/filestack-php | filestack/Filelink.php | Filelink.upscale | public function upscale($noise = 'none', $style = 'photo', $upscale = true)
{
$options = [
'n' => $noise,
's' => $style,
'u' => $upscale ? 'true' : 'false'
];
// call TransformationMixin function
$this->setTransformUrl('upscale', $options);
return $this;
} | php | public function upscale($noise = 'none', $style = 'photo', $upscale = true)
{
$options = [
'n' => $noise,
's' => $style,
'u' => $upscale ? 'true' : 'false'
];
// call TransformationMixin function
$this->setTransformUrl('upscale', $options);
return $this;
} | [
"public",
"function",
"upscale",
"(",
"$",
"noise",
"=",
"'none'",
",",
"$",
"style",
"=",
"'photo'",
",",
"$",
"upscale",
"=",
"true",
")",
"{",
"$",
"options",
"=",
"[",
"'n'",
"=>",
"$",
"noise",
",",
"'s'",
"=>",
"$",
"style",
",",
"'u'",
"=>... | Set this Filelink's transform_url to include the upscale task
@param string $noise none, low, medium or high
Setting to reduce the level of noise in
an image. This noise reduction is performed
algorithmically and the aggressiveness of
the noise reduction is determined by low,
medium and high gradations.
@param string $style artwork or photo
If the image being upscaled is a drawing
or piece of artwork with smooth lines, you
will receive better results from the upscaling
process if you also include the artwork
style parameter.
@param bool $upscale True will generate an image that is 2x the
dimensions of the original. If false is
passed as part of the task, then features
like noise reduction can be used without
changing the resolution of the image.
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Set",
"this",
"Filelink",
"s",
"transform_url",
"to",
"include",
"the",
"upscale",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1080-L1092 |
41,026 | filestack/filestack-php | filestack/Filelink.php | Filelink.vignette | public function vignette($amount = 20, $background = 'white', $blurmode = 'gaussian')
{
$options = [
'a' => $amount,
'b' => $background,
'm' => $blurmode
];
// call TransformationMixin function
$this->setTransformUrl('vignette', $options);
return $this;
} | php | public function vignette($amount = 20, $background = 'white', $blurmode = 'gaussian')
{
$options = [
'a' => $amount,
'b' => $background,
'm' => $blurmode
];
// call TransformationMixin function
$this->setTransformUrl('vignette', $options);
return $this;
} | [
"public",
"function",
"vignette",
"(",
"$",
"amount",
"=",
"20",
",",
"$",
"background",
"=",
"'white'",
",",
"$",
"blurmode",
"=",
"'gaussian'",
")",
"{",
"$",
"options",
"=",
"[",
"'a'",
"=>",
"$",
"amount",
",",
"'b'",
"=>",
"$",
"background",
","... | Set this Filelink's transform_url to include the vignette task
@param int $amount The opacity of the vignette effect (0-100)
@param string $background Sets the background color to display behind
the image. This can be the word for a color,
or the hex color code, e.g. ('red' or 'FF0000')
@param string $blurmode linear or gaussian
Controls the type of blur applied to the
vignette - linear or gaussian. The vignette
effect uses gaussian blur by default because
it produces a more defined vignette around
the image. Specifying linear is faster,
but produces a less-defined blur effect,
even at higher amounts.
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Set",
"this",
"Filelink",
"s",
"transform_url",
"to",
"include",
"the",
"vignette",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1114-L1126 |
41,027 | filestack/filestack-php | filestack/Filelink.php | Filelink.watermark | public function watermark($file_handle, $position = 'center', $size = 100)
{
$options = [
'f' => $file_handle,
'p' => $position,
's' => $size
];
// call TransformationMixin function
$this->setTransformUrl('watermark', $options);
return $this;
} | php | public function watermark($file_handle, $position = 'center', $size = 100)
{
$options = [
'f' => $file_handle,
'p' => $position,
's' => $size
];
// call TransformationMixin function
$this->setTransformUrl('watermark', $options);
return $this;
} | [
"public",
"function",
"watermark",
"(",
"$",
"file_handle",
",",
"$",
"position",
"=",
"'center'",
",",
"$",
"size",
"=",
"100",
")",
"{",
"$",
"options",
"=",
"[",
"'f'",
"=>",
"$",
"file_handle",
",",
"'p'",
"=>",
"$",
"position",
",",
"'s'",
"=>",... | Set this Filelink's transform_url to include the watermark task
@param string $file_handle The Filestack handle of the image that
you want to layer on top of another
image as a watermark.
@param string $position top, middle, bottom, left, center, or right
The position of the overlayed image. These
values can be paired as well like position:
[top,right].
@param int $size The size of the overlayed image as a percentage
of its original size. The value must be an
integer between 1 and 500.
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Set",
"this",
"Filelink",
"s",
"transform_url",
"to",
"include",
"the",
"watermark",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1146-L1158 |
41,028 | filestack/filestack-php | filestack/Filelink.php | Filelink.getMetaData | public function getMetaData($fields = [])
{
// call CommonMixin function
$result = $this->sendGetMetaData($this->url(), $fields, $this->security);
foreach ($result as $key => $value) {
$this->metadata[$key] = $value;
}
return $result;
} | php | public function getMetaData($fields = [])
{
// call CommonMixin function
$result = $this->sendGetMetaData($this->url(), $fields, $this->security);
foreach ($result as $key => $value) {
$this->metadata[$key] = $value;
}
return $result;
} | [
"public",
"function",
"getMetaData",
"(",
"$",
"fields",
"=",
"[",
"]",
")",
"{",
"// call CommonMixin function",
"$",
"result",
"=",
"$",
"this",
"->",
"sendGetMetaData",
"(",
"$",
"this",
"->",
"url",
"(",
")",
",",
"$",
"fields",
",",
"$",
"this",
"... | Get metadata of filehandle
@param array $fields optional, specific fields to retrieve.
possible fields are:
mimetype, filename, size, width, height,
location, path, container, exif,
uploaded (timestamp), writable,
cloud, source_url
@throws FilestackException if API call fails
@return array | [
"Get",
"metadata",
"of",
"filehandle"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1188-L1198 |
41,029 | filestack/filestack-php | filestack/Filelink.php | Filelink.delete | public function delete()
{
// call CommonMixin function
$result = $this->sendDelete($this->handle, $this->api_key, $this->security);
return $result;
} | php | public function delete()
{
// call CommonMixin function
$result = $this->sendDelete($this->handle, $this->api_key, $this->security);
return $result;
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"// call CommonMixin function",
"$",
"result",
"=",
"$",
"this",
"->",
"sendDelete",
"(",
"$",
"this",
"->",
"handle",
",",
"$",
"this",
"->",
"api_key",
",",
"$",
"this",
"->",
"security",
")",
";",
"return... | Delete this filelink from cloud storage
@throws FilestackException if API call fails, e.g 404 file not found
@return bool (true = delete success, false = failed) | [
"Delete",
"this",
"filelink",
"from",
"cloud",
"storage"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1208-L1213 |
41,030 | filestack/filestack-php | filestack/Filelink.php | Filelink.download | public function download($destination)
{
// call CommonMixin function
$result = $this->sendDownload($this->url(), $destination, $this->security);
return $result;
} | php | public function download($destination)
{
// call CommonMixin function
$result = $this->sendDownload($this->url(), $destination, $this->security);
return $result;
} | [
"public",
"function",
"download",
"(",
"$",
"destination",
")",
"{",
"// call CommonMixin function",
"$",
"result",
"=",
"$",
"this",
"->",
"sendDownload",
"(",
"$",
"this",
"->",
"url",
"(",
")",
",",
"$",
"destination",
",",
"$",
"this",
"->",
"security"... | Download filelink as a file, saving it to specified destination
@param string $destination destination filepath to save to, can
be folder name (defaults to stored filename)
@throws FilestackException if API call fails
@return bool (true = download success, false = failed) | [
"Download",
"filelink",
"as",
"a",
"file",
"saving",
"it",
"to",
"specified",
"destination"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1225-L1230 |
41,031 | filestack/filestack-php | filestack/Filelink.php | Filelink.overwrite | public function overwrite($filepath)
{
$result = $this->sendOverwrite($filepath,
$this->handle, $this->api_key, $this->security);
// update metadata
$this->metadata['filename'] = $result->metadata['filename'];
$this->metadata['mimetype'] = $result->metadata['mimetype'];
$this->metadata['size'] = $result->metadata['size'];
return true;
} | php | public function overwrite($filepath)
{
$result = $this->sendOverwrite($filepath,
$this->handle, $this->api_key, $this->security);
// update metadata
$this->metadata['filename'] = $result->metadata['filename'];
$this->metadata['mimetype'] = $result->metadata['mimetype'];
$this->metadata['size'] = $result->metadata['size'];
return true;
} | [
"public",
"function",
"overwrite",
"(",
"$",
"filepath",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"sendOverwrite",
"(",
"$",
"filepath",
",",
"$",
"this",
"->",
"handle",
",",
"$",
"this",
"->",
"api_key",
",",
"$",
"this",
"->",
"security",
... | Overwrite this filelink in cloud storage
@param string $filepath real path to file
@throws FilestackException if API call fails, e.g 404 file not found
@return boolean | [
"Overwrite",
"this",
"filelink",
"in",
"cloud",
"storage"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1241-L1252 |
41,032 | filestack/filestack-php | filestack/Filelink.php | Filelink.save | public function save($options = [])
{
$this->initTransformUrl();
$this->transform_url = $this->insertTransformStr($this->transform_url,
'store', $options);
// call CommonMixin function
$response = $this->sendRequest('GET', $this->transform_url);
$filelink = $this->handleResponseCreateFilelink($response);
return $filelink;
} | php | public function save($options = [])
{
$this->initTransformUrl();
$this->transform_url = $this->insertTransformStr($this->transform_url,
'store', $options);
// call CommonMixin function
$response = $this->sendRequest('GET', $this->transform_url);
$filelink = $this->handleResponseCreateFilelink($response);
return $filelink;
} | [
"public",
"function",
"save",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"initTransformUrl",
"(",
")",
";",
"$",
"this",
"->",
"transform_url",
"=",
"$",
"this",
"->",
"insertTransformStr",
"(",
"$",
"this",
"->",
"transform_url",
... | Save this transformed filelink in cloud storage
@param array $options array of store options
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack\Filelink | [
"Save",
"this",
"transformed",
"filelink",
"in",
"cloud",
"storage"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1273-L1284 |
41,033 | filestack/filestack-php | filestack/Filelink.php | Filelink.setTransformUrl | public function setTransformUrl($method, $options = [])
{
$this->initTransformUrl();
$this->transform_url = $this->insertTransformStr($this->transform_url,
$method, $options);
} | php | public function setTransformUrl($method, $options = [])
{
$this->initTransformUrl();
$this->transform_url = $this->insertTransformStr($this->transform_url,
$method, $options);
} | [
"public",
"function",
"setTransformUrl",
"(",
"$",
"method",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"initTransformUrl",
"(",
")",
";",
"$",
"this",
"->",
"transform_url",
"=",
"$",
"this",
"->",
"insertTransformStr",
"(",
"$",
... | Append or Create a task to the transformation url for this filelink
@param array $options task options, e.g. ['b' => '00FF00', 'd' => '45']
@throws FilestackException if API call fails, e.g 404 file not found
@return void | [
"Append",
"or",
"Create",
"a",
"task",
"to",
"the",
"transformation",
"url",
"for",
"this",
"filelink"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1295-L1300 |
41,034 | filestack/filestack-php | filestack/Filelink.php | Filelink.transform | public function transform($transform_tasks)
{
// call TransformationMixin
$result = $this->sendTransform($this->handle,
$transform_tasks, $this->security);
return $result;
} | php | public function transform($transform_tasks)
{
// call TransformationMixin
$result = $this->sendTransform($this->handle,
$transform_tasks, $this->security);
return $result;
} | [
"public",
"function",
"transform",
"(",
"$",
"transform_tasks",
")",
"{",
"// call TransformationMixin",
"$",
"result",
"=",
"$",
"this",
"->",
"sendTransform",
"(",
"$",
"this",
"->",
"handle",
",",
"$",
"transform_tasks",
",",
"$",
"this",
"->",
"security",
... | Applied array of transformation tasks to this file link.
@param array $transform_tasks array of transformation tasks and
optional attributes per task
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack\Filelink or contents | [
"Applied",
"array",
"of",
"transformation",
"tasks",
"to",
"this",
"file",
"link",
"."
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1338-L1345 |
41,035 | filestack/filestack-php | filestack/Filelink.php | Filelink.initTransformUrl | protected function initTransformUrl()
{
if (!$this->transform_url) {
// security in a different format for transformations
$security_str = $this->security ?
sprintf('/security=policy:%s,signature:%s',
$this->security->policy,
$this->security->signature
) : '';
$this->transform_url = sprintf(FilestackConfig::CDN_URL . '%s/%s',
$security_str,
$this->handle);
}
} | php | protected function initTransformUrl()
{
if (!$this->transform_url) {
// security in a different format for transformations
$security_str = $this->security ?
sprintf('/security=policy:%s,signature:%s',
$this->security->policy,
$this->security->signature
) : '';
$this->transform_url = sprintf(FilestackConfig::CDN_URL . '%s/%s',
$security_str,
$this->handle);
}
} | [
"protected",
"function",
"initTransformUrl",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"transform_url",
")",
"{",
"// security in a different format for transformations",
"$",
"security_str",
"=",
"$",
"this",
"->",
"security",
"?",
"sprintf",
"(",
"'/secu... | Initialize transform url if it doesnt exist | [
"Initialize",
"transform",
"url",
"if",
"it",
"doesnt",
"exist"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/Filelink.php#L1390-L1404 |
41,036 | filestack/filestack-php | filestack/mixins/CommonMixin.php | CommonMixin.isUrl | public function isUrl($url)
{
$path = parse_url($url, PHP_URL_PATH);
$encoded_path = array_map('urlencode', explode('/', $path));
$url = str_replace($path, implode('/', $encoded_path), $url);
return filter_var($url, FILTER_VALIDATE_URL);
} | php | public function isUrl($url)
{
$path = parse_url($url, PHP_URL_PATH);
$encoded_path = array_map('urlencode', explode('/', $path));
$url = str_replace($path, implode('/', $encoded_path), $url);
return filter_var($url, FILTER_VALIDATE_URL);
} | [
"public",
"function",
"isUrl",
"(",
"$",
"url",
")",
"{",
"$",
"path",
"=",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_PATH",
")",
";",
"$",
"encoded_path",
"=",
"array_map",
"(",
"'urlencode'",
",",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
")"... | Check if a string is a valid url.
@param string $url url string to check
@return bool | [
"Check",
"if",
"a",
"string",
"is",
"a",
"valid",
"url",
"."
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/CommonMixin.php#L33-L40 |
41,037 | filestack/filestack-php | filestack/mixins/CommonMixin.php | CommonMixin.sendDelete | public function sendDelete($handle, $api_key, $security)
{
$url = sprintf('%s/file/%s?key=%s',
FilestackConfig::API_URL, $handle, $api_key);
if ($security) {
$url = $security->signUrl($url);
}
$response = $this->sendRequest('DELETE', $url);
$status_code = $response->getStatusCode();
// handle response
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
return true;
} | php | public function sendDelete($handle, $api_key, $security)
{
$url = sprintf('%s/file/%s?key=%s',
FilestackConfig::API_URL, $handle, $api_key);
if ($security) {
$url = $security->signUrl($url);
}
$response = $this->sendRequest('DELETE', $url);
$status_code = $response->getStatusCode();
// handle response
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
return true;
} | [
"public",
"function",
"sendDelete",
"(",
"$",
"handle",
",",
"$",
"api_key",
",",
"$",
"security",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s/file/%s?key=%s'",
",",
"FilestackConfig",
"::",
"API_URL",
",",
"$",
"handle",
",",
"$",
"api_key",
")",
";... | Delete a file from cloud storage
@param string $handle Filestack file handle to delete
@param string $api_key Filestack API Key
@param FilestackSecurity $security Filestack security object is
required for this call
@throws FilestackException if API call fails, e.g 404 file not found
@return bool (true = delete success, false = failed) | [
"Delete",
"a",
"file",
"from",
"cloud",
"storage"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/CommonMixin.php#L67-L85 |
41,038 | filestack/filestack-php | filestack/mixins/CommonMixin.php | CommonMixin.sendDownload | protected function sendDownload($url, $destination, $security = null)
{
if (is_dir($destination)) {
// destination is a folder
$json = $this->sendGetMetaData($url, ["filename"], $security);
$remote_filename = $json['filename'];
$destination .= $remote_filename;
}
// sign url if security is passed in
if ($security) {
$url = $security->signUrl($url);
}
# send request
$options = ['sink' => $destination];
$url .= '&dl=true';
$response = $this->sendRequest('GET', $url, $options);
$status_code = $response->getStatusCode();
// handle response
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
return true;
} | php | protected function sendDownload($url, $destination, $security = null)
{
if (is_dir($destination)) {
// destination is a folder
$json = $this->sendGetMetaData($url, ["filename"], $security);
$remote_filename = $json['filename'];
$destination .= $remote_filename;
}
// sign url if security is passed in
if ($security) {
$url = $security->signUrl($url);
}
# send request
$options = ['sink' => $destination];
$url .= '&dl=true';
$response = $this->sendRequest('GET', $url, $options);
$status_code = $response->getStatusCode();
// handle response
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
return true;
} | [
"protected",
"function",
"sendDownload",
"(",
"$",
"url",
",",
"$",
"destination",
",",
"$",
"security",
"=",
"null",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"destination",
")",
")",
"{",
"// destination is a folder",
"$",
"json",
"=",
"$",
"this",
"->"... | Download a file to specified destination given a url
@param string $url Filestack file url
@param string $destination destination filepath to save to,
can be a directory name
@param FilestackSecurity $security Filestack security object if
security settings is turned on
@throws FilestackException if API call fails, e.g 404 file not found
@return bool (true = download success, false = failed) | [
"Download",
"a",
"file",
"to",
"specified",
"destination",
"given",
"a",
"url"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/CommonMixin.php#L100-L127 |
41,039 | filestack/filestack-php | filestack/mixins/CommonMixin.php | CommonMixin.sendGetContent | protected function sendGetContent($url, $security = null)
{
// sign url if security is passed in
if ($security) {
$url = $security->signUrl($url);
}
$response = $this->sendRequest('GET', $url);
$status_code = $response->getStatusCode();
// handle response
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
$content = $response->getBody()->getContents();
return $content;
} | php | protected function sendGetContent($url, $security = null)
{
// sign url if security is passed in
if ($security) {
$url = $security->signUrl($url);
}
$response = $this->sendRequest('GET', $url);
$status_code = $response->getStatusCode();
// handle response
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
$content = $response->getBody()->getContents();
return $content;
} | [
"protected",
"function",
"sendGetContent",
"(",
"$",
"url",
",",
"$",
"security",
"=",
"null",
")",
"{",
"// sign url if security is passed in",
"if",
"(",
"$",
"security",
")",
"{",
"$",
"url",
"=",
"$",
"security",
"->",
"signUrl",
"(",
"$",
"url",
")",
... | Get the content of a file.
@param string $url Filestack file url
@param FilestackSecurity $security Filestack security object if
security settings is turned on
@throws FilestackException if API call fails, e.g 404 file not found
@return string (file content) | [
"Get",
"the",
"content",
"of",
"a",
"file",
"."
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/CommonMixin.php#L140-L158 |
41,040 | filestack/filestack-php | filestack/mixins/CommonMixin.php | CommonMixin.sendGetMetaData | protected function sendGetMetaData($url, $fields = [], $security = null)
{
$url .= "/metadata?";
foreach ($fields as $field_name) {
$url .= "&$field_name=true";
}
// sign url if security is passed in
if ($security) {
$url = $security->signUrl($url);
}
$response = $this->sendRequest('GET', $url);
$status_code = $response->getStatusCode();
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
$json_response = json_decode($response->getBody(), true);
return $json_response;
} | php | protected function sendGetMetaData($url, $fields = [], $security = null)
{
$url .= "/metadata?";
foreach ($fields as $field_name) {
$url .= "&$field_name=true";
}
// sign url if security is passed in
if ($security) {
$url = $security->signUrl($url);
}
$response = $this->sendRequest('GET', $url);
$status_code = $response->getStatusCode();
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
$json_response = json_decode($response->getBody(), true);
return $json_response;
} | [
"protected",
"function",
"sendGetMetaData",
"(",
"$",
"url",
",",
"$",
"fields",
"=",
"[",
"]",
",",
"$",
"security",
"=",
"null",
")",
"{",
"$",
"url",
".=",
"\"/metadata?\"",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field_name",
")",
"{",
"$... | Get the metadata of a remote file. Will only retrieve specific fields
if optional fields are passed in
@param $url url of file
@param $fields optional, specific fields to retrieve.
values are: mimetype, filename, size,
width, height,location, path,
container, exif, uploaded (timestamp),
writable, cloud, source_url
@param FilestackSecurity $security Filestack security object if
security settings is turned on
@throws FilestackException if API call fails, e.g 400 bad request
@return array | [
"Get",
"the",
"metadata",
"of",
"a",
"remote",
"file",
".",
"Will",
"only",
"retrieve",
"specific",
"fields",
"if",
"optional",
"fields",
"are",
"passed",
"in"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/CommonMixin.php#L177-L199 |
41,041 | filestack/filestack-php | filestack/mixins/CommonMixin.php | CommonMixin.handleResponseCreateFilelink | protected function handleResponseCreateFilelink($response)
{
$status_code = $response->getStatusCode();
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
$json_response = json_decode($response->getBody(), true);
$url = $json_response['url'];
$file_handle = substr($url, strrpos($url, '/') + 1);
$filelink = new Filelink($file_handle, $this->api_key, $this->security);
$filelink->metadata['filename'] = $json_response['filename'];
$filelink->metadata['size'] = $json_response['size'];
$filelink->metadata['mimetype'] = 'unknown';
if (isset($json_response['type'])) {
$filelink->metadata['mimetype'] = $json_response['type'];
} elseif (isset($json_response['mimetype'])) {
$filelink->metadata['mimetype'] = $json_response['mimetype'];
}
return $filelink;
} | php | protected function handleResponseCreateFilelink($response)
{
$status_code = $response->getStatusCode();
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
$json_response = json_decode($response->getBody(), true);
$url = $json_response['url'];
$file_handle = substr($url, strrpos($url, '/') + 1);
$filelink = new Filelink($file_handle, $this->api_key, $this->security);
$filelink->metadata['filename'] = $json_response['filename'];
$filelink->metadata['size'] = $json_response['size'];
$filelink->metadata['mimetype'] = 'unknown';
if (isset($json_response['type'])) {
$filelink->metadata['mimetype'] = $json_response['type'];
} elseif (isset($json_response['mimetype'])) {
$filelink->metadata['mimetype'] = $json_response['mimetype'];
}
return $filelink;
} | [
"protected",
"function",
"handleResponseCreateFilelink",
"(",
"$",
"response",
")",
"{",
"$",
"status_code",
"=",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"if",
"(",
"$",
"status_code",
"!==",
"200",
")",
"{",
"throw",
"new",
"FilestackException"... | Handle a Filestack response and create a filelink object
@param Http\Message\Response $response response object
@throws FilestackException if statuscode is not OK
@return Filestack\Filelink | [
"Handle",
"a",
"Filestack",
"response",
"and",
"create",
"a",
"filelink",
"object"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/CommonMixin.php#L309-L333 |
41,042 | filestack/filestack-php | filestack/mixins/CommonMixin.php | CommonMixin.handleResponseDecodeJson | protected function handleResponseDecodeJson($response)
{
$status_code = $response->getStatusCode();
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
$json_response = json_decode($response->getBody(), true);
return $json_response;
} | php | protected function handleResponseDecodeJson($response)
{
$status_code = $response->getStatusCode();
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
$json_response = json_decode($response->getBody(), true);
return $json_response;
} | [
"protected",
"function",
"handleResponseDecodeJson",
"(",
"$",
"response",
")",
"{",
"$",
"status_code",
"=",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"if",
"(",
"$",
"status_code",
"!==",
"200",
")",
"{",
"throw",
"new",
"FilestackException",
... | Handles a response. decode and return json if 200,
throws exception otherwise.
@param Response $response the response object
@throws FilestackException if statuscode is not OK
@return array (decoded json) | [
"Handles",
"a",
"response",
".",
"decode",
"and",
"return",
"json",
"if",
"200",
"throws",
"exception",
"otherwise",
"."
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/CommonMixin.php#L345-L354 |
41,043 | filestack/filestack-php | filestack/mixins/CommonMixin.php | CommonMixin.getSourceHeaders | protected function getSourceHeaders()
{
$headers = [];
if (!$this->user_agent_header || !$this->source_header) {
$version = trim(file_get_contents(__DIR__ . '/../../VERSION'));
if (!$this->user_agent_header) {
$this->user_agent_header = sprintf('filestack-php-%s',
$version);
}
if (!$this->source_header) {
$this->source_header = sprintf('PHP-%s',
$version);
}
}
$headers['user-agent'] = $this->user_agent_header;
$headers['filestack-source'] = $this->source_header;
//user_agent_header
return $headers;
} | php | protected function getSourceHeaders()
{
$headers = [];
if (!$this->user_agent_header || !$this->source_header) {
$version = trim(file_get_contents(__DIR__ . '/../../VERSION'));
if (!$this->user_agent_header) {
$this->user_agent_header = sprintf('filestack-php-%s',
$version);
}
if (!$this->source_header) {
$this->source_header = sprintf('PHP-%s',
$version);
}
}
$headers['user-agent'] = $this->user_agent_header;
$headers['filestack-source'] = $this->source_header;
//user_agent_header
return $headers;
} | [
"protected",
"function",
"getSourceHeaders",
"(",
")",
"{",
"$",
"headers",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"user_agent_header",
"||",
"!",
"$",
"this",
"->",
"source_header",
")",
"{",
"$",
"version",
"=",
"trim",
"(",
"file_get... | Get source header | [
"Get",
"source",
"header"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/CommonMixin.php#L376-L399 |
41,044 | filestack/filestack-php | filestack/FilestackSecurity.php | FilestackSecurity.generate | private function generate($secret, $options = [])
{
if (!$secret) {
throw new FilestackException("Secret can not be empty", 400);
}
// check that options passed in are valid (on allowed list)
$this->validateOptions($options);
// set encoded values to policy and signature
$policy = json_encode($options);
$policy = $this->urlsafeB64encode($policy);
$signature = $this->createSignature($policy, $secret);
return ['policy' => $policy, 'signature' => $signature];
} | php | private function generate($secret, $options = [])
{
if (!$secret) {
throw new FilestackException("Secret can not be empty", 400);
}
// check that options passed in are valid (on allowed list)
$this->validateOptions($options);
// set encoded values to policy and signature
$policy = json_encode($options);
$policy = $this->urlsafeB64encode($policy);
$signature = $this->createSignature($policy, $secret);
return ['policy' => $policy, 'signature' => $signature];
} | [
"private",
"function",
"generate",
"(",
"$",
"secret",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"secret",
")",
"{",
"throw",
"new",
"FilestackException",
"(",
"\"Secret can not be empty\"",
",",
"400",
")",
";",
"}",
"// check t... | generate a security policy and signature
@param string $secret random hash secret
@param array $options array of policy options
@throws FilestackException e.g. policy option not allowed
@return array ['policy'=>'encrypted_value', 'signature'=>'encrypted_value'] | [
"generate",
"a",
"security",
"policy",
"and",
"signature"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/FilestackSecurity.php#L79-L94 |
41,045 | filestack/filestack-php | filestack/FilestackSecurity.php | FilestackSecurity.signUrl | public function signUrl($url)
{
if (strrpos($url, '?') === false) {
// append ? if one doesn't exist
$url .= '?';
}
return sprintf('%s&policy=%s&signature=%s',
$url, $this->policy, $this->signature);
} | php | public function signUrl($url)
{
if (strrpos($url, '?') === false) {
// append ? if one doesn't exist
$url .= '?';
}
return sprintf('%s&policy=%s&signature=%s',
$url, $this->policy, $this->signature);
} | [
"public",
"function",
"signUrl",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"strrpos",
"(",
"$",
"url",
",",
"'?'",
")",
"===",
"false",
")",
"{",
"// append ? if one doesn't exist",
"$",
"url",
".=",
"'?'",
";",
"}",
"return",
"sprintf",
"(",
"'%s&policy=%s&... | Append policy and signature to url
@param string $url the url to sign
@return string (url with policy and signature appended) | [
"Append",
"policy",
"and",
"signature",
"to",
"url"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/FilestackSecurity.php#L103-L111 |
41,046 | filestack/filestack-php | filestack/FilestackSecurity.php | FilestackSecurity.verify | public function verify($policy, $secret)
{
try {
$result = $this->generate($secret, $policy);
} catch (FilestackException $e) {
return false;
}
return $result;
} | php | public function verify($policy, $secret)
{
try {
$result = $this->generate($secret, $policy);
} catch (FilestackException $e) {
return false;
}
return $result;
} | [
"public",
"function",
"verify",
"(",
"$",
"policy",
",",
"$",
"secret",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"generate",
"(",
"$",
"secret",
",",
"$",
"policy",
")",
";",
"}",
"catch",
"(",
"FilestackException",
"$",
"e",
")... | Verify that a policy is valid
@param array $policy policy to verify
@param string? $secret security secret
@return bool | [
"Verify",
"that",
"a",
"policy",
"is",
"valid"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/FilestackSecurity.php#L121-L130 |
41,047 | filestack/filestack-php | filestack/FilestackSecurity.php | FilestackSecurity.validateOptions | protected function validateOptions($options)
{
foreach ($options as $key => $value) {
if (!in_array($key, $this->allowed_options)) {
throw new FilestackException("Invalid policy option: $key:$value", 400);
}
}
return true;
} | php | protected function validateOptions($options)
{
foreach ($options as $key => $value) {
if (!in_array($key, $this->allowed_options)) {
throw new FilestackException("Invalid policy option: $key:$value", 400);
}
}
return true;
} | [
"protected",
"function",
"validateOptions",
"(",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"allowed_options",
")",
")... | Validate options are allowed
@param array $options array of options
@throws FilestackException e.g. policy option not allowed
@return bool | [
"Validate",
"options",
"are",
"allowed"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/FilestackSecurity.php#L155-L164 |
41,048 | filestack/filestack-php | filestack/UploadProcessor.php | UploadProcessor.registerUploadTask | public function registerUploadTask($api_key, $metadata)
{
$data = [];
$this->appendData($data, 'apikey', $api_key);
$this->appendData($data, 'filename', $metadata['filename']);
$this->appendData($data, 'mimetype', $metadata['mimetype']);
$this->appendData($data, 'size', $metadata['filesize']);
$this->appendData($data, 'store_location', $metadata['location']);
$this->appendData($data, 'multipart', true);
array_push($data, ['name' => 'files',
'contents' => '',
'filename' => $metadata['filename']
]);
$this->appendSecurity($data);
$url = FilestackConfig::UPLOAD_URL . '/multipart/start';
$response = $this->sendRequest('POST', $url, ['multipart' => $data]);
$json = $this->handleResponseDecodeJson($response);
return $json;
} | php | public function registerUploadTask($api_key, $metadata)
{
$data = [];
$this->appendData($data, 'apikey', $api_key);
$this->appendData($data, 'filename', $metadata['filename']);
$this->appendData($data, 'mimetype', $metadata['mimetype']);
$this->appendData($data, 'size', $metadata['filesize']);
$this->appendData($data, 'store_location', $metadata['location']);
$this->appendData($data, 'multipart', true);
array_push($data, ['name' => 'files',
'contents' => '',
'filename' => $metadata['filename']
]);
$this->appendSecurity($data);
$url = FilestackConfig::UPLOAD_URL . '/multipart/start';
$response = $this->sendRequest('POST', $url, ['multipart' => $data]);
$json = $this->handleResponseDecodeJson($response);
return $json;
} | [
"public",
"function",
"registerUploadTask",
"(",
"$",
"api_key",
",",
"$",
"metadata",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"appendData",
"(",
"$",
"data",
",",
"'apikey'",
",",
"$",
"api_key",
")",
";",
"$",
"this",
"->",
... | Trigger the start of an upload task
@param string $api_key Filestack API Key
@param string $metadata metadata of file: filename, filesize,
mimetype, location
@throws FilestackException if API call fails
@return json | [
"Trigger",
"the",
"start",
"of",
"an",
"upload",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/UploadProcessor.php#L66-L88 |
41,049 | filestack/filestack-php | filestack/UploadProcessor.php | UploadProcessor.run | public function run($api_key, $metadata, $upload_data)
{
$parts = $this->createParts($api_key, $metadata, $upload_data);
// upload parts
$result = $this->processParts($parts);
// parts uploaded, register complete and wait for acceptance
$wait_attempts = FilestackConfig::UPLOAD_WAIT_ATTEMPTS;
$wait_time = FilestackConfig::UPLOAD_WAIT_SECONDS;
$accepted_code = HttpStatusCodes::HTTP_ACCEPTED;
$completed_status_code = $accepted_code;
$completed_result = ['status_code' => 0, 'filelink' => []];
while ($completed_status_code == $accepted_code &&
$wait_attempts > 0) {
$completed_result = $this->registerComplete($api_key, $result,
$upload_data, $metadata);
$completed_status_code = $completed_result['status_code'];
if ($completed_status_code == $accepted_code) {
sleep($wait_time);
}
$wait_attempts--;
}
return $completed_result;
} | php | public function run($api_key, $metadata, $upload_data)
{
$parts = $this->createParts($api_key, $metadata, $upload_data);
// upload parts
$result = $this->processParts($parts);
// parts uploaded, register complete and wait for acceptance
$wait_attempts = FilestackConfig::UPLOAD_WAIT_ATTEMPTS;
$wait_time = FilestackConfig::UPLOAD_WAIT_SECONDS;
$accepted_code = HttpStatusCodes::HTTP_ACCEPTED;
$completed_status_code = $accepted_code;
$completed_result = ['status_code' => 0, 'filelink' => []];
while ($completed_status_code == $accepted_code &&
$wait_attempts > 0) {
$completed_result = $this->registerComplete($api_key, $result,
$upload_data, $metadata);
$completed_status_code = $completed_result['status_code'];
if ($completed_status_code == $accepted_code) {
sleep($wait_time);
}
$wait_attempts--;
}
return $completed_result;
} | [
"public",
"function",
"run",
"(",
"$",
"api_key",
",",
"$",
"metadata",
",",
"$",
"upload_data",
")",
"{",
"$",
"parts",
"=",
"$",
"this",
"->",
"createParts",
"(",
"$",
"api_key",
",",
"$",
"metadata",
",",
"$",
"upload_data",
")",
";",
"// upload par... | Run upload process, including splitting up the file and sending parts
concurrently in chunks.
@param string $api_key Filestack API Key
@param string $metadata metadata of file: filename, filesize,
mimetype, location
@param array $upload_data filestack upload data from register
call: uri, region, upload_id
@throws FilestackException if API call fails
@return array['statuscode', 'json'] | [
"Run",
"upload",
"process",
"including",
"splitting",
"up",
"the",
"file",
"and",
"sending",
"parts",
"concurrently",
"in",
"chunks",
"."
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/UploadProcessor.php#L104-L133 |
41,050 | filestack/filestack-php | filestack/UploadProcessor.php | UploadProcessor.createParts | protected function createParts($api_key, $metadata, $upload_data)
{
$parts = [];
$max_part_size = FilestackConfig::UPLOAD_PART_SIZE;
$max_chunk_size = FilestackConfig::UPLOAD_CHUNK_SIZE;
$num_parts = ceil($metadata['filesize'] / $max_part_size);
$seek_point = 0;
// create each part of file
for ($i=0; $i<$num_parts; $i++) {
// create chunks of file
$chunk_offset = 0;
$chunks = [];
if ($this->intelligent) {
// split part into chunks
$num_chunks = 1;
$chunk_size = $metadata['filesize'];
if ($metadata['filesize'] > $max_chunk_size) {
$num_chunks = ceil($max_part_size / $max_chunk_size);
$chunk_size = $max_chunk_size;
}
while ($num_chunks > 0) {
array_push($chunks, [
'offset' => $chunk_offset,
'seek_point' => $seek_point,
'size' => $chunk_size,
]);
$chunk_offset += $max_chunk_size;
$seek_point += $max_chunk_size;
if ($seek_point >= $metadata['filesize']) {
break;
}
$num_chunks--;
}
}
else {
// 1 part = 1 chunk
array_push($chunks, [
'offset' => 0,
'seek_point' => $seek_point,
'size' => $max_part_size
]);
$seek_point += $max_part_size;
}
array_push($parts, [
'api_key' => $api_key,
'part_num' => $i + 1,
'uri' => $upload_data['uri'],
'region' => $upload_data['region'],
'upload_id' => $upload_data['upload_id'],
'filepath' => $metadata['filepath'],
'filename' => $metadata['filename'],
'filesize' => $metadata['filesize'],
'mimetype' => $metadata['mimetype'],
'location' => $metadata['location'],
'chunks' => $chunks
]);
}
return $parts;
} | php | protected function createParts($api_key, $metadata, $upload_data)
{
$parts = [];
$max_part_size = FilestackConfig::UPLOAD_PART_SIZE;
$max_chunk_size = FilestackConfig::UPLOAD_CHUNK_SIZE;
$num_parts = ceil($metadata['filesize'] / $max_part_size);
$seek_point = 0;
// create each part of file
for ($i=0; $i<$num_parts; $i++) {
// create chunks of file
$chunk_offset = 0;
$chunks = [];
if ($this->intelligent) {
// split part into chunks
$num_chunks = 1;
$chunk_size = $metadata['filesize'];
if ($metadata['filesize'] > $max_chunk_size) {
$num_chunks = ceil($max_part_size / $max_chunk_size);
$chunk_size = $max_chunk_size;
}
while ($num_chunks > 0) {
array_push($chunks, [
'offset' => $chunk_offset,
'seek_point' => $seek_point,
'size' => $chunk_size,
]);
$chunk_offset += $max_chunk_size;
$seek_point += $max_chunk_size;
if ($seek_point >= $metadata['filesize']) {
break;
}
$num_chunks--;
}
}
else {
// 1 part = 1 chunk
array_push($chunks, [
'offset' => 0,
'seek_point' => $seek_point,
'size' => $max_part_size
]);
$seek_point += $max_part_size;
}
array_push($parts, [
'api_key' => $api_key,
'part_num' => $i + 1,
'uri' => $upload_data['uri'],
'region' => $upload_data['region'],
'upload_id' => $upload_data['upload_id'],
'filepath' => $metadata['filepath'],
'filename' => $metadata['filename'],
'filesize' => $metadata['filesize'],
'mimetype' => $metadata['mimetype'],
'location' => $metadata['location'],
'chunks' => $chunks
]);
}
return $parts;
} | [
"protected",
"function",
"createParts",
"(",
"$",
"api_key",
",",
"$",
"metadata",
",",
"$",
"upload_data",
")",
"{",
"$",
"parts",
"=",
"[",
"]",
";",
"$",
"max_part_size",
"=",
"FilestackConfig",
"::",
"UPLOAD_PART_SIZE",
";",
"$",
"max_chunk_size",
"=",
... | Take a file and separate it into parts, creating an array of parts to
process.
@param string $api_key Filestack API Key
@param array $metadata Metadata of file: filename, filesize,
mimetype, location
@param array $upload_data filestack upload data from register
call: uri, region, upload_id
@return Filestack/Filelink or file content | [
"Take",
"a",
"file",
"and",
"separate",
"it",
"into",
"parts",
"creating",
"an",
"array",
"of",
"parts",
"to",
"process",
"."
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/UploadProcessor.php#L147-L216 |
41,051 | filestack/filestack-php | filestack/UploadProcessor.php | UploadProcessor.processParts | protected function processParts($parts)
{
$num_parts = count($parts);
$parts_etags = [];
$parts_completed = 0;
$max_retries = FilestackConfig::MAX_RETRIES;
$current_part_index = 0;
while($parts_completed < $num_parts) {
$part = $parts[$current_part_index];
$part['part_size'] = 0;
$chunks = $part['chunks'];
// process chunks of current part
$promises = $this->processChunks($part, $chunks);
// sends s3 chunks asyncronously
$s3_results = $this->settlePromises($promises);
$this->handleS3PromisesResult($s3_results);
// handle fulfilled promises
if ($this->intelligent) {
// commit part
$this->commitPart($part);
}
else {
$part_num = array_key_exists('part_num', $part) ?
$part['part_num'] : 1;
$this->multipartGetTags($part_num, $s3_results, $parts_etags);
}
unset($promises);
unset($s3_results);
$current_part_index++;
$parts_completed++;
}
if (!$this->intelligent) {
return implode(';', $parts_etags);
}
return $parts_completed;
} | php | protected function processParts($parts)
{
$num_parts = count($parts);
$parts_etags = [];
$parts_completed = 0;
$max_retries = FilestackConfig::MAX_RETRIES;
$current_part_index = 0;
while($parts_completed < $num_parts) {
$part = $parts[$current_part_index];
$part['part_size'] = 0;
$chunks = $part['chunks'];
// process chunks of current part
$promises = $this->processChunks($part, $chunks);
// sends s3 chunks asyncronously
$s3_results = $this->settlePromises($promises);
$this->handleS3PromisesResult($s3_results);
// handle fulfilled promises
if ($this->intelligent) {
// commit part
$this->commitPart($part);
}
else {
$part_num = array_key_exists('part_num', $part) ?
$part['part_num'] : 1;
$this->multipartGetTags($part_num, $s3_results, $parts_etags);
}
unset($promises);
unset($s3_results);
$current_part_index++;
$parts_completed++;
}
if (!$this->intelligent) {
return implode(';', $parts_etags);
}
return $parts_completed;
} | [
"protected",
"function",
"processParts",
"(",
"$",
"parts",
")",
"{",
"$",
"num_parts",
"=",
"count",
"(",
"$",
"parts",
")",
";",
"$",
"parts_etags",
"=",
"[",
"]",
";",
"$",
"parts_completed",
"=",
"0",
";",
"$",
"max_retries",
"=",
"FilestackConfig",
... | Process the parts of the file to server.
@param array $parts array of parts to process
@throws FilestackException if API call fails
@return json | [
"Process",
"the",
"parts",
"of",
"the",
"file",
"to",
"server",
"."
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/UploadProcessor.php#L227-L272 |
41,052 | filestack/filestack-php | filestack/UploadProcessor.php | UploadProcessor.processChunks | protected function processChunks($part, $chunks)
{
$upload_url = FilestackConfig::UPLOAD_URL . '/multipart/upload';
$max_retries = FilestackConfig::MAX_RETRIES;
$num_retries = 0;
$promises = [];
if (!array_key_exists('part_size', $part)) {
$part['part_size'] = 0;
}
for($i=0; $i<count($chunks); $i++) {
$current_chunk = $chunks[$i];
$seek_point = $current_chunk['seek_point'];
$chunk_content = $this->getChunkContent($part['filepath'], $seek_point,
$current_chunk['size']);
$current_chunk['md5'] = trim(base64_encode(md5($chunk_content, true)));
$current_chunk['size'] = strlen($chunk_content);
$part['part_size'] += $current_chunk['size'];
$data = $this->buildChunkData($part, $current_chunk);
$response = $this->sendRequest('POST', $upload_url, ['multipart' => $data]);
try {
$json = $this->handleResponseDecodeJson($response);
$url = $json['url'];
$headers = $json['headers'];
$this->appendPromise($promises, 'PUT', $url, [
'body' => $chunk_content,
'headers' => $headers
]);
}
catch(FilestackException $e) {
$status_code = $e->getCode();
if ($this->intelligent && $num_retries < $max_retries) {
$num_retries++;
if (HttpStatusCodes::isServerError($status_code)) {
$wait_time = $this->get_retry_miliseconds($num_retries);
usleep($wait_time * 1000);
}
if (HttpStatusCodes::isNetworkError($status_code) ||
HttpStatusCodes::isServerError($status_code)) {
// reset index to retry this iteration
$i--;
}
continue;
}
throw new FilestackException($e->getMessage(), $status_code);
}
}
return $promises;
} | php | protected function processChunks($part, $chunks)
{
$upload_url = FilestackConfig::UPLOAD_URL . '/multipart/upload';
$max_retries = FilestackConfig::MAX_RETRIES;
$num_retries = 0;
$promises = [];
if (!array_key_exists('part_size', $part)) {
$part['part_size'] = 0;
}
for($i=0; $i<count($chunks); $i++) {
$current_chunk = $chunks[$i];
$seek_point = $current_chunk['seek_point'];
$chunk_content = $this->getChunkContent($part['filepath'], $seek_point,
$current_chunk['size']);
$current_chunk['md5'] = trim(base64_encode(md5($chunk_content, true)));
$current_chunk['size'] = strlen($chunk_content);
$part['part_size'] += $current_chunk['size'];
$data = $this->buildChunkData($part, $current_chunk);
$response = $this->sendRequest('POST', $upload_url, ['multipart' => $data]);
try {
$json = $this->handleResponseDecodeJson($response);
$url = $json['url'];
$headers = $json['headers'];
$this->appendPromise($promises, 'PUT', $url, [
'body' => $chunk_content,
'headers' => $headers
]);
}
catch(FilestackException $e) {
$status_code = $e->getCode();
if ($this->intelligent && $num_retries < $max_retries) {
$num_retries++;
if (HttpStatusCodes::isServerError($status_code)) {
$wait_time = $this->get_retry_miliseconds($num_retries);
usleep($wait_time * 1000);
}
if (HttpStatusCodes::isNetworkError($status_code) ||
HttpStatusCodes::isServerError($status_code)) {
// reset index to retry this iteration
$i--;
}
continue;
}
throw new FilestackException($e->getMessage(), $status_code);
}
}
return $promises;
} | [
"protected",
"function",
"processChunks",
"(",
"$",
"part",
",",
"$",
"chunks",
")",
"{",
"$",
"upload_url",
"=",
"FilestackConfig",
"::",
"UPLOAD_URL",
".",
"'/multipart/upload'",
";",
"$",
"max_retries",
"=",
"FilestackConfig",
"::",
"MAX_RETRIES",
";",
"$",
... | Process the chunks of a part the file to server.
@param object $part the part to process
@param array $chunks the chunks of part to process
@throws FilestackException if API call fails
@return Promises to send Asyncronously to s3 | [
"Process",
"the",
"chunks",
"of",
"a",
"part",
"the",
"file",
"to",
"server",
"."
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/UploadProcessor.php#L284-L342 |
41,053 | filestack/filestack-php | filestack/UploadProcessor.php | UploadProcessor.commitPart | protected function commitPart($part)
{
$commit_url = FilestackConfig::UPLOAD_URL . '/multipart/commit';
$commit_data = $this->buildCommitData($part);
$response = $this->sendRequest('POST', $commit_url,
['multipart' => $commit_data]);
$status_code = $response->getStatusCode();
if ($status_code !== 200) {
throw new FilestackException($response->getBody(),
$status_code);
}
return $status_code;
} | php | protected function commitPart($part)
{
$commit_url = FilestackConfig::UPLOAD_URL . '/multipart/commit';
$commit_data = $this->buildCommitData($part);
$response = $this->sendRequest('POST', $commit_url,
['multipart' => $commit_data]);
$status_code = $response->getStatusCode();
if ($status_code !== 200) {
throw new FilestackException($response->getBody(),
$status_code);
}
return $status_code;
} | [
"protected",
"function",
"commitPart",
"(",
"$",
"part",
")",
"{",
"$",
"commit_url",
"=",
"FilestackConfig",
"::",
"UPLOAD_URL",
".",
"'/multipart/commit'",
";",
"$",
"commit_data",
"=",
"$",
"this",
"->",
"buildCommitData",
"(",
"$",
"part",
")",
";",
"$",... | All chunks of this part has been uploaded. We have to call commit to
let the uploader API knows.
@param object $part the part to process
@throws FilestackException if API call fails
@return int status_code | [
"All",
"chunks",
"of",
"this",
"part",
"has",
"been",
"uploaded",
".",
"We",
"have",
"to",
"call",
"commit",
"to",
"let",
"the",
"uploader",
"API",
"knows",
"."
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/UploadProcessor.php#L354-L368 |
41,054 | filestack/filestack-php | filestack/UploadProcessor.php | UploadProcessor.registerComplete | protected function registerComplete($api_key, $parts_etags, $upload_data,
$metadata)
{
$data = [];
$this->appendData($data, 'apikey', $api_key);
$this->appendData($data, 'uri', $upload_data['uri']);
$this->appendData($data, 'region', $upload_data['region']);
$this->appendData($data, 'upload_id', $upload_data['upload_id']);
$this->appendData($data, 'size', $metadata['filesize']);
$this->appendData($data, 'filename', $metadata['filename']);
$this->appendData($data, 'mimetype', $metadata['mimetype']);
$this->appendData($data, 'store_location', $metadata['location']);
$this->appendData($data, 'parts', $parts_etags);
if ($this->intelligent) {
$this->appendData($data, 'multipart', true);
}
array_push($data, ['name' => 'files',
'contents' => '',
'filename' => $metadata['filename']
]);
$this->appendSecurity($data);
$url = FilestackConfig::UPLOAD_URL . '/multipart/complete';
$response = $this->sendRequest('POST', $url, ['multipart' => $data]);
$status_code = $response->getStatusCode();
$filelink = null;
if ($status_code == 200) {
$filelink = $this->handleResponseCreateFilelink($response);
}
return ['status_code' => $status_code, 'filelink' => $filelink];
} | php | protected function registerComplete($api_key, $parts_etags, $upload_data,
$metadata)
{
$data = [];
$this->appendData($data, 'apikey', $api_key);
$this->appendData($data, 'uri', $upload_data['uri']);
$this->appendData($data, 'region', $upload_data['region']);
$this->appendData($data, 'upload_id', $upload_data['upload_id']);
$this->appendData($data, 'size', $metadata['filesize']);
$this->appendData($data, 'filename', $metadata['filename']);
$this->appendData($data, 'mimetype', $metadata['mimetype']);
$this->appendData($data, 'store_location', $metadata['location']);
$this->appendData($data, 'parts', $parts_etags);
if ($this->intelligent) {
$this->appendData($data, 'multipart', true);
}
array_push($data, ['name' => 'files',
'contents' => '',
'filename' => $metadata['filename']
]);
$this->appendSecurity($data);
$url = FilestackConfig::UPLOAD_URL . '/multipart/complete';
$response = $this->sendRequest('POST', $url, ['multipart' => $data]);
$status_code = $response->getStatusCode();
$filelink = null;
if ($status_code == 200) {
$filelink = $this->handleResponseCreateFilelink($response);
}
return ['status_code' => $status_code, 'filelink' => $filelink];
} | [
"protected",
"function",
"registerComplete",
"(",
"$",
"api_key",
",",
"$",
"parts_etags",
",",
"$",
"upload_data",
",",
"$",
"metadata",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"appendData",
"(",
"$",
"data",
",",
"'apikey'",
","... | Trigger the end of an upload task
@param string $api_key Filestack API Key
@param string $parts_etags parts:etags, semicolon separated
e.g. '1:etag_1;2:etag_2;3:etag_3
@param array $upload_data upload data from register
call: uri, region, upload_id
@param string $metadata metadata of file: filename,
filesize, mimetype, location
@throws FilestackException if API call fails
@return json | [
"Trigger",
"the",
"end",
"of",
"an",
"upload",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/UploadProcessor.php#L422-L458 |
41,055 | filestack/filestack-php | filestack/UploadProcessor.php | UploadProcessor.buildChunkData | protected function buildChunkData($part, $chunk_data)
{
$data = [];
$this->appendData($data, 'apikey', $part['api_key']);
$this->appendData($data, 'uri', $part['uri']);
$this->appendData($data, 'region', $part['region']);
$this->appendData($data, 'upload_id', $part['upload_id']);
$this->appendData($data, 'part', $part['part_num']);
$this->appendData($data, 'store_location', $part['location']);
$this->appendData($data, 'md5', $chunk_data['md5']);
$this->appendData($data, 'size', $chunk_data['size']);
if ($this->intelligent) {
$this->appendData($data, 'multipart', true);
$this->appendData($data, 'offset', $chunk_data['offset']);
}
$this->appendSecurity($data);
array_push($data, [
'name' => 'files',
'contents' => '',
'filename' => $part['filename']]);
return $data;
} | php | protected function buildChunkData($part, $chunk_data)
{
$data = [];
$this->appendData($data, 'apikey', $part['api_key']);
$this->appendData($data, 'uri', $part['uri']);
$this->appendData($data, 'region', $part['region']);
$this->appendData($data, 'upload_id', $part['upload_id']);
$this->appendData($data, 'part', $part['part_num']);
$this->appendData($data, 'store_location', $part['location']);
$this->appendData($data, 'md5', $chunk_data['md5']);
$this->appendData($data, 'size', $chunk_data['size']);
if ($this->intelligent) {
$this->appendData($data, 'multipart', true);
$this->appendData($data, 'offset', $chunk_data['offset']);
}
$this->appendSecurity($data);
array_push($data, [
'name' => 'files',
'contents' => '',
'filename' => $part['filename']]);
return $data;
} | [
"protected",
"function",
"buildChunkData",
"(",
"$",
"part",
",",
"$",
"chunk_data",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"appendData",
"(",
"$",
"data",
",",
"'apikey'",
",",
"$",
"part",
"[",
"'api_key'",
"]",
")",
";",
"... | Create data multipart data for multipart upload api request | [
"Create",
"data",
"multipart",
"data",
"for",
"multipart",
"upload",
"api",
"request"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/UploadProcessor.php#L463-L489 |
41,056 | filestack/filestack-php | filestack/UploadProcessor.php | UploadProcessor.getChunkContent | protected function getChunkContent($filepath, $seek_point, $chunk_size) {
$handle = fopen($filepath, 'r');
fseek($handle, $seek_point);
$chunk = fread($handle, $chunk_size);
fclose($handle);
$handle = null;
return $chunk;
} | php | protected function getChunkContent($filepath, $seek_point, $chunk_size) {
$handle = fopen($filepath, 'r');
fseek($handle, $seek_point);
$chunk = fread($handle, $chunk_size);
fclose($handle);
$handle = null;
return $chunk;
} | [
"protected",
"function",
"getChunkContent",
"(",
"$",
"filepath",
",",
"$",
"seek_point",
",",
"$",
"chunk_size",
")",
"{",
"$",
"handle",
"=",
"fopen",
"(",
"$",
"filepath",
",",
"'r'",
")",
";",
"fseek",
"(",
"$",
"handle",
",",
"$",
"seek_point",
")... | Get a chunk from a file given starting seek point. | [
"Get",
"a",
"chunk",
"from",
"a",
"file",
"given",
"starting",
"seek",
"point",
"."
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/UploadProcessor.php#L515-L523 |
41,057 | filestack/filestack-php | filestack/UploadProcessor.php | UploadProcessor.appendSecurity | protected function appendSecurity(&$data)
{
if ($this->security) {
$this->appendData($data, 'policy', $this->security->policy);
$this->appendData($data, 'signature', $this->security->signature);
}
} | php | protected function appendSecurity(&$data)
{
if ($this->security) {
$this->appendData($data, 'policy', $this->security->policy);
$this->appendData($data, 'signature', $this->security->signature);
}
} | [
"protected",
"function",
"appendSecurity",
"(",
"&",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"security",
")",
"{",
"$",
"this",
"->",
"appendData",
"(",
"$",
"data",
",",
"'policy'",
",",
"$",
"this",
"->",
"security",
"->",
"policy",
")... | Append security params | [
"Append",
"security",
"params"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/UploadProcessor.php#L528-L534 |
41,058 | filestack/filestack-php | filestack/UploadProcessor.php | UploadProcessor.multipartGetTags | protected function multipartGetTags($part_num, $s3_results, &$parts_etags)
{
foreach ($s3_results as $result) {
if (isset($result['value']) && $result['value']) {
$etag = $result['value']->getHeader('ETag')[0];
$part_etag = sprintf('%s:%s', $part_num, $etag);
array_push($parts_etags, $part_etag);
}
}
} | php | protected function multipartGetTags($part_num, $s3_results, &$parts_etags)
{
foreach ($s3_results as $result) {
if (isset($result['value']) && $result['value']) {
$etag = $result['value']->getHeader('ETag')[0];
$part_etag = sprintf('%s:%s', $part_num, $etag);
array_push($parts_etags, $part_etag);
}
}
} | [
"protected",
"function",
"multipartGetTags",
"(",
"$",
"part_num",
",",
"$",
"s3_results",
",",
"&",
"$",
"parts_etags",
")",
"{",
"foreach",
"(",
"$",
"s3_results",
"as",
"$",
"result",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'value'",
... | Parse results of s3 calls and append to parts_etags array | [
"Parse",
"results",
"of",
"s3",
"calls",
"and",
"append",
"to",
"parts_etags",
"array"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/UploadProcessor.php#L539-L548 |
41,059 | filestack/filestack-php | filestack/UploadProcessor.php | UploadProcessor.handleS3PromisesResult | protected function handleS3PromisesResult($s3_results)
{
foreach ($s3_results as $promise) {
if ($promise['state'] !== 'fulfilled') {
$code = HttpStatusCodes::HTTP_SERVICE_UNAVAILABLE;
if (array_key_exists('value', $promise)) {
$response = $promise['value'];
$code = $response->getStatusCode();
}
throw new FilestackException("Errored uploading to s3", $code);
}
}
} | php | protected function handleS3PromisesResult($s3_results)
{
foreach ($s3_results as $promise) {
if ($promise['state'] !== 'fulfilled') {
$code = HttpStatusCodes::HTTP_SERVICE_UNAVAILABLE;
if (array_key_exists('value', $promise)) {
$response = $promise['value'];
$code = $response->getStatusCode();
}
throw new FilestackException("Errored uploading to s3", $code);
}
}
} | [
"protected",
"function",
"handleS3PromisesResult",
"(",
"$",
"s3_results",
")",
"{",
"foreach",
"(",
"$",
"s3_results",
"as",
"$",
"promise",
")",
"{",
"if",
"(",
"$",
"promise",
"[",
"'state'",
"]",
"!==",
"'fulfilled'",
")",
"{",
"$",
"code",
"=",
"Htt... | Handle results of promises after async calls | [
"Handle",
"results",
"of",
"promises",
"after",
"async",
"calls"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/UploadProcessor.php#L553-L565 |
41,060 | filestack/filestack-php | filestack/mixins/TransformationMixin.php | TransformationMixin.getTransformStr | public function getTransformStr($taskname, $process_attrs)
{
$tranform_str = $taskname;
if (count($process_attrs) > 0) {
$tranform_str .= '=';
}
// append attributes if exists
foreach ($process_attrs as $key => $value) {
$encoded_value = gettype($value) === 'string' ?
urlencode($value) : urlencode(json_encode($value));
$tranform_str .= sprintf('%s:%s,',
urlencode($key),
$encoded_value);
}
// remove last comma
if (count($process_attrs) > 0) {
$tranform_str = substr($tranform_str, 0, strlen($tranform_str) - 1);
}
return $tranform_str;
} | php | public function getTransformStr($taskname, $process_attrs)
{
$tranform_str = $taskname;
if (count($process_attrs) > 0) {
$tranform_str .= '=';
}
// append attributes if exists
foreach ($process_attrs as $key => $value) {
$encoded_value = gettype($value) === 'string' ?
urlencode($value) : urlencode(json_encode($value));
$tranform_str .= sprintf('%s:%s,',
urlencode($key),
$encoded_value);
}
// remove last comma
if (count($process_attrs) > 0) {
$tranform_str = substr($tranform_str, 0, strlen($tranform_str) - 1);
}
return $tranform_str;
} | [
"public",
"function",
"getTransformStr",
"(",
"$",
"taskname",
",",
"$",
"process_attrs",
")",
"{",
"$",
"tranform_str",
"=",
"$",
"taskname",
";",
"if",
"(",
"count",
"(",
"$",
"process_attrs",
")",
">",
"0",
")",
"{",
"$",
"tranform_str",
".=",
"'='",
... | Return the URL portion of a transformation task
@param string $taskname name of task, e.g. 'crop', 'resize', etc.
@param array $process_attrs attributes replated to this task
@throws Filestack\FilestackException
@return Transformation object | [
"Return",
"the",
"URL",
"portion",
"of",
"a",
"transformation",
"task"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/TransformationMixin.php#L23-L46 |
41,061 | filestack/filestack-php | filestack/mixins/TransformationMixin.php | TransformationMixin.insertTransformStr | protected function insertTransformStr($url, $taskname, $process_attrs = [])
{
$transform_str = $this->getTransformStr($taskname, $process_attrs);
// insert transform_url before file handle
$url = substr($url, 0, strrpos($url, '/'));
return "$url/$transform_str/" . $this->handle;
} | php | protected function insertTransformStr($url, $taskname, $process_attrs = [])
{
$transform_str = $this->getTransformStr($taskname, $process_attrs);
// insert transform_url before file handle
$url = substr($url, 0, strrpos($url, '/'));
return "$url/$transform_str/" . $this->handle;
} | [
"protected",
"function",
"insertTransformStr",
"(",
"$",
"url",
",",
"$",
"taskname",
",",
"$",
"process_attrs",
"=",
"[",
"]",
")",
"{",
"$",
"transform_str",
"=",
"$",
"this",
"->",
"getTransformStr",
"(",
"$",
"taskname",
",",
"$",
"process_attrs",
")",... | Insert a transformation task into existing url
@param string $url url to insert task into
@param string $taskname name of task, e.g. 'crop', 'resize', etc.
@param array $process_attrs attributes replated to this task
@throws Filestack\FilestackException
@return Transformation object | [
"Insert",
"a",
"transformation",
"task",
"into",
"existing",
"url"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/TransformationMixin.php#L59-L67 |
41,062 | filestack/filestack-php | filestack/mixins/TransformationMixin.php | TransformationMixin.sendDebug | public function sendDebug($transform_url, $api_key, $security = null)
{
$transform_str = str_replace(FilestackConfig::CDN_URL . '/', '', $transform_url);
$debug_url = sprintf('%s/%s/debug/%s', FilestackConfig::CDN_URL,
$api_key, $transform_str);
if ($security) {
$debug_url = $security->signUrl($debug_url);
}
// call CommonMixin function
$response = $this->sendRequest('GET', $debug_url);
$status_code = $response->getStatusCode();
// handle response
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
$json_response = json_decode($response->getBody(), true);
return $json_response;
} | php | public function sendDebug($transform_url, $api_key, $security = null)
{
$transform_str = str_replace(FilestackConfig::CDN_URL . '/', '', $transform_url);
$debug_url = sprintf('%s/%s/debug/%s', FilestackConfig::CDN_URL,
$api_key, $transform_str);
if ($security) {
$debug_url = $security->signUrl($debug_url);
}
// call CommonMixin function
$response = $this->sendRequest('GET', $debug_url);
$status_code = $response->getStatusCode();
// handle response
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
$json_response = json_decode($response->getBody(), true);
return $json_response;
} | [
"public",
"function",
"sendDebug",
"(",
"$",
"transform_url",
",",
"$",
"api_key",
",",
"$",
"security",
"=",
"null",
")",
"{",
"$",
"transform_str",
"=",
"str_replace",
"(",
"FilestackConfig",
"::",
"CDN_URL",
".",
"'/'",
",",
"''",
",",
"$",
"transform_u... | Send debug call
@param string $transform_url the transformation url
@param string $api_key Filestack API Key
@param FilestackSecurity $security Filestack Security object if
enabled
@throws FilestackException if API call fails, e.g 404 file not found
@return json object | [
"Send",
"debug",
"call"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/TransformationMixin.php#L81-L103 |
41,063 | filestack/filestack-php | filestack/mixins/TransformationMixin.php | TransformationMixin.sendTransform | public function sendTransform($resource, $transform_tasks, $security = null)
{
// add store method if one does not exists
if (!array_key_exists('store', $transform_tasks)) {
$transform_tasks['store'] = [];
}
$tasks_str = $this->createTransformStr($transform_tasks);
$transform_url = $this->createTransformUrl(
$this->api_key,
'image',
$resource,
$tasks_str,
$security
);
// call CommonMixin function
$response = $this->sendRequest('GET', $transform_url);
$filelink = $this->handleResponseCreateFilelink($response);
return $filelink;
} | php | public function sendTransform($resource, $transform_tasks, $security = null)
{
// add store method if one does not exists
if (!array_key_exists('store', $transform_tasks)) {
$transform_tasks['store'] = [];
}
$tasks_str = $this->createTransformStr($transform_tasks);
$transform_url = $this->createTransformUrl(
$this->api_key,
'image',
$resource,
$tasks_str,
$security
);
// call CommonMixin function
$response = $this->sendRequest('GET', $transform_url);
$filelink = $this->handleResponseCreateFilelink($response);
return $filelink;
} | [
"public",
"function",
"sendTransform",
"(",
"$",
"resource",
",",
"$",
"transform_tasks",
",",
"$",
"security",
"=",
"null",
")",
"{",
"// add store method if one does not exists",
"if",
"(",
"!",
"array_key_exists",
"(",
"'store'",
",",
"$",
"transform_tasks",
")... | Applied array of transformation tasks to handle or external url
@param string $resource url or filestack handle
@param array $transform_tasks array of transformation tasks
@param FilestackSecurity $security Filestack Security object if
enabled
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack\Filelink | [
"Applied",
"array",
"of",
"transformation",
"tasks",
"to",
"handle",
"or",
"external",
"url"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/TransformationMixin.php#L117-L138 |
41,064 | filestack/filestack-php | filestack/mixins/TransformationMixin.php | TransformationMixin.sendVideoConvert | public function sendVideoConvert($resource, $transform_tasks,
$security = null, $force = false)
{
$tasks_str = $this->createTransformStr($transform_tasks);
$transform_url = $this->createTransformUrl(
$this->api_key,
'video',
$resource,
$tasks_str,
$security
);
// force restart task?
if ($force) {
$transform_url .= '&force=true';
}
// call CommonMixin function
$response = $this->sendRequest('GET', $transform_url);
$status_code = $response->getStatusCode();
// handle response
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
$json_response = json_decode($response->getBody(), true);
$uuid = $json_response['uuid'];
return [
'uuid' => $uuid,
'conversion_url' => $transform_url
];
} | php | public function sendVideoConvert($resource, $transform_tasks,
$security = null, $force = false)
{
$tasks_str = $this->createTransformStr($transform_tasks);
$transform_url = $this->createTransformUrl(
$this->api_key,
'video',
$resource,
$tasks_str,
$security
);
// force restart task?
if ($force) {
$transform_url .= '&force=true';
}
// call CommonMixin function
$response = $this->sendRequest('GET', $transform_url);
$status_code = $response->getStatusCode();
// handle response
if ($status_code !== 200) {
throw new FilestackException($response->getBody(), $status_code);
}
$json_response = json_decode($response->getBody(), true);
$uuid = $json_response['uuid'];
return [
'uuid' => $uuid,
'conversion_url' => $transform_url
];
} | [
"public",
"function",
"sendVideoConvert",
"(",
"$",
"resource",
",",
"$",
"transform_tasks",
",",
"$",
"security",
"=",
"null",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"tasks_str",
"=",
"$",
"this",
"->",
"createTransformStr",
"(",
"$",
"transform_... | Send video_convert request to API
@param string $resource url or filestack handle
@param array $transform_tasks array of transformation tasks
@param FilestackSecurity $security Filestack Security object if
enabled
@throws FilestackException if API call fails, e.g 404 file not found
@return string (uuid of conversion task) | [
"Send",
"video_convert",
"request",
"to",
"API"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/TransformationMixin.php#L152-L185 |
41,065 | filestack/filestack-php | filestack/mixins/TransformationMixin.php | TransformationMixin.getConvertTaskInfo | public function getConvertTaskInfo($conversion_url)
{
$response = $this->sendRequest('GET', $conversion_url);
$json = $this->handleResponseDecodeJson($response);
return $json;
} | php | public function getConvertTaskInfo($conversion_url)
{
$response = $this->sendRequest('GET', $conversion_url);
$json = $this->handleResponseDecodeJson($response);
return $json;
} | [
"public",
"function",
"getConvertTaskInfo",
"(",
"$",
"conversion_url",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"sendRequest",
"(",
"'GET'",
",",
"$",
"conversion_url",
")",
";",
"$",
"json",
"=",
"$",
"this",
"->",
"handleResponseDecodeJson",
"("... | Get the info of a conversion task given the conversion url
@param string $conversion_url the conversion task url
@throws FilestackException if API call fails
@return json | [
"Get",
"the",
"info",
"of",
"a",
"conversion",
"task",
"given",
"the",
"conversion",
"url"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/mixins/TransformationMixin.php#L196-L202 |
41,066 | filestack/filestack-php | filestack/FilestackClient.php | FilestackClient.getContent | public function getContent($url)
{
if (!$this->isUrl($url)) { // CommonMixin
$url = $this->getCdnUrl($url);
}
// call CommonMixin function
$result = $this->sendGetContent($url, $this->security);
return $result;
} | php | public function getContent($url)
{
if (!$this->isUrl($url)) { // CommonMixin
$url = $this->getCdnUrl($url);
}
// call CommonMixin function
$result = $this->sendGetContent($url, $this->security);
return $result;
} | [
"public",
"function",
"getContent",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isUrl",
"(",
"$",
"url",
")",
")",
"{",
"// CommonMixin",
"$",
"url",
"=",
"$",
"this",
"->",
"getCdnUrl",
"(",
"$",
"url",
")",
";",
"}",
"// call... | Get the content of file
@param string $url Filestack file url or handle
@throws FilestackException if API call fails, e.g 404 file not found
@return string (file content) | [
"Get",
"the",
"content",
"of",
"file"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/FilestackClient.php#L78-L88 |
41,067 | filestack/filestack-php | filestack/FilestackClient.php | FilestackClient.getMetaData | public function getMetaData($url, $fields = [])
{
if (!$this->isUrl($url)) { // CommonMixin
$url = $this->getCdnUrl($url);
}
// call CommonMixin function
$result = $this->sendGetMetaData($url, $fields, $this->security);
return $result;
} | php | public function getMetaData($url, $fields = [])
{
if (!$this->isUrl($url)) { // CommonMixin
$url = $this->getCdnUrl($url);
}
// call CommonMixin function
$result = $this->sendGetMetaData($url, $fields, $this->security);
return $result;
} | [
"public",
"function",
"getMetaData",
"(",
"$",
"url",
",",
"$",
"fields",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isUrl",
"(",
"$",
"url",
")",
")",
"{",
"// CommonMixin",
"$",
"url",
"=",
"$",
"this",
"->",
"getCdnUrl",
"(",... | Get metadata of a file
@param string $url Filestack file url or handle
@param array $fields optional, specific fields to retrieve.
possible fields are:
mimetype, filename, size, width, height,
location, path, container, exif,
uploaded (timestamp), writable,
cloud, source_url
@throws FilestackException if API call fails
@return array | [
"Get",
"metadata",
"of",
"a",
"file"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/FilestackClient.php#L105-L114 |
41,068 | filestack/filestack-php | filestack/FilestackClient.php | FilestackClient.debug | public function debug($resource, $transform_tasks)
{
// call TransformationMixin functions
$tasks_str = $this->createTransformStr($transform_tasks);
$transform_url = $this->createTransformUrl(
$this->api_key,
'image',
$resource,
$tasks_str,
$this->security
);
$json_response = $this->sendDebug($transform_url, $this->api_key, $this->security);
return $json_response;
} | php | public function debug($resource, $transform_tasks)
{
// call TransformationMixin functions
$tasks_str = $this->createTransformStr($transform_tasks);
$transform_url = $this->createTransformUrl(
$this->api_key,
'image',
$resource,
$tasks_str,
$this->security
);
$json_response = $this->sendDebug($transform_url, $this->api_key, $this->security);
return $json_response;
} | [
"public",
"function",
"debug",
"(",
"$",
"resource",
",",
"$",
"transform_tasks",
")",
"{",
"// call TransformationMixin functions",
"$",
"tasks_str",
"=",
"$",
"this",
"->",
"createTransformStr",
"(",
"$",
"transform_tasks",
")",
";",
"$",
"transform_url",
"=",
... | Debug transform tasks
@param string $resource url or file handle
@param array $transform_tasks Transformation tasks to debug
@throws FilestackException if API call fails, e.g 404 file not found
@return json response | [
"Debug",
"transform",
"tasks"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/FilestackClient.php#L506-L520 |
41,069 | filestack/filestack-php | filestack/FilestackClient.php | FilestackClient.download | public function download($url, $destination)
{
if (!$this->isUrl($url)) { // CommonMixin
$url = $this->getCdnUrl($url);
}
// call CommonMixin function
$result = $this->sendDownload($url, $destination, $this->security);
return $result;
} | php | public function download($url, $destination)
{
if (!$this->isUrl($url)) { // CommonMixin
$url = $this->getCdnUrl($url);
}
// call CommonMixin function
$result = $this->sendDownload($url, $destination, $this->security);
return $result;
} | [
"public",
"function",
"download",
"(",
"$",
"url",
",",
"$",
"destination",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isUrl",
"(",
"$",
"url",
")",
")",
"{",
"// CommonMixin",
"$",
"url",
"=",
"$",
"this",
"->",
"getCdnUrl",
"(",
"$",
"url",
... | Download a file, saving it to specified destination
@param string $url Filestack file url or handle
@param string $destination destination filepath to save to, can
be foldername (defaults to stored filename)
@throws FilestackException if API call fails
@return bool (true = download success, false = failed) | [
"Download",
"a",
"file",
"saving",
"it",
"to",
"specified",
"destination"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/FilestackClient.php#L549-L559 |
41,070 | filestack/filestack-php | filestack/FilestackClient.php | FilestackClient.screenshot | public function screenshot($url, $store_options = [],
$agent = 'desktop', $mode = 'all', $width = 1024, $height = 768, $delay = 0)
{
$process_attrs = [
'a' => $agent,
'm' => $mode,
'w' => $width,
'h' => $height,
'd' => $delay
];
$transform_tasks = [
'urlscreenshot' => $process_attrs
];
if (!empty($store_options)) {
$transform_tasks['store'] = $store_options;
}
// call TransformationMixin function
$result = $this->sendTransform($url, $transform_tasks, $this->security);
return $result;
} | php | public function screenshot($url, $store_options = [],
$agent = 'desktop', $mode = 'all', $width = 1024, $height = 768, $delay = 0)
{
$process_attrs = [
'a' => $agent,
'm' => $mode,
'w' => $width,
'h' => $height,
'd' => $delay
];
$transform_tasks = [
'urlscreenshot' => $process_attrs
];
if (!empty($store_options)) {
$transform_tasks['store'] = $store_options;
}
// call TransformationMixin function
$result = $this->sendTransform($url, $transform_tasks, $this->security);
return $result;
} | [
"public",
"function",
"screenshot",
"(",
"$",
"url",
",",
"$",
"store_options",
"=",
"[",
"]",
",",
"$",
"agent",
"=",
"'desktop'",
",",
"$",
"mode",
"=",
"'all'",
",",
"$",
"width",
"=",
"1024",
",",
"$",
"height",
"=",
"768",
",",
"$",
"delay",
... | Take a screenshot of a URL
@param string $url URL to screenshot
@param string $store_options optional store values
@param string $agent desktop or mobile
@param string $mode all or window
@param int $width Designate the width of the browser window. The
width is 1024 by default, but can be set to
anywhere between 1 to 1920.
@param int $height Designate the height of the browser window.
The height is 768 by default, but can be set
to anywhere between 1 to 1080.
@param int $delay Tell URL Screenshot to wait x milliseconds before
capturing the webpage. Sometimes pages take
longer to load, so you may need to delay the
capture in order to make sure the page is
rendered before the screenshot is taken. The
delay must be an integer between 0 and 10000.
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink | [
"Take",
"a",
"screenshot",
"of",
"a",
"URL"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/FilestackClient.php#L603-L626 |
41,071 | filestack/filestack-php | filestack/FilestackClient.php | FilestackClient.transform | public function transform($url, $transform_tasks)
{
// call TransformationMixin
$result = $this->sendTransform($url, $transform_tasks, $this->security);
return $result;
} | php | public function transform($url, $transform_tasks)
{
// call TransformationMixin
$result = $this->sendTransform($url, $transform_tasks, $this->security);
return $result;
} | [
"public",
"function",
"transform",
"(",
"$",
"url",
",",
"$",
"transform_tasks",
")",
"{",
"// call TransformationMixin",
"$",
"result",
"=",
"$",
"this",
"->",
"sendTransform",
"(",
"$",
"url",
",",
"$",
"transform_tasks",
",",
"$",
"this",
"->",
"security"... | Applied array of transformation tasks to a url
@param string $url url to transform
@param array $transform_tasks array of transformation tasks and
optional attributes per task
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack\Filelink or file content | [
"Applied",
"array",
"of",
"transformation",
"tasks",
"to",
"a",
"url"
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/FilestackClient.php#L639-L644 |
41,072 | filestack/filestack-php | filestack/FilestackClient.php | FilestackClient.upload | public function upload($filepath, $options = [])
{
if (!file_exists($filepath)) {
throw new FilestackException("File not found", 400);
}
$location = 's3';
if (array_key_exists('location', $options)) {
$location = $options['location'];
}
$filename = basename($filepath);
if (array_key_exists('filename', $options)) {
$filename = $options['filename'];
}
$mimetype = mime_content_type($filepath);
if (array_key_exists('mimetype', $options)) {
$mimetype = $options['mimetype'];
}
$metadata = [
'filepath' => $filepath,
'filename' => $filename,
'filesize' => filesize($filepath),
'mimetype' => $mimetype,
'location' => $location,
];
// register job
$upload_data = $this->upload_processor->registerUploadTask($this->api_key,
$metadata, $this->security);
// Intelligent Ingestion option
if (array_key_exists('intelligent', $options) &&
$this->upload_processor->intelligenceEnabled($upload_data)) {
$this->upload_processor->setIntelligent($options['intelligent']);
}
$result = $this->upload_processor->run($this->api_key,
$metadata,
$upload_data);
$filelink = $result['filelink'];
return $filelink;
} | php | public function upload($filepath, $options = [])
{
if (!file_exists($filepath)) {
throw new FilestackException("File not found", 400);
}
$location = 's3';
if (array_key_exists('location', $options)) {
$location = $options['location'];
}
$filename = basename($filepath);
if (array_key_exists('filename', $options)) {
$filename = $options['filename'];
}
$mimetype = mime_content_type($filepath);
if (array_key_exists('mimetype', $options)) {
$mimetype = $options['mimetype'];
}
$metadata = [
'filepath' => $filepath,
'filename' => $filename,
'filesize' => filesize($filepath),
'mimetype' => $mimetype,
'location' => $location,
];
// register job
$upload_data = $this->upload_processor->registerUploadTask($this->api_key,
$metadata, $this->security);
// Intelligent Ingestion option
if (array_key_exists('intelligent', $options) &&
$this->upload_processor->intelligenceEnabled($upload_data)) {
$this->upload_processor->setIntelligent($options['intelligent']);
}
$result = $this->upload_processor->run($this->api_key,
$metadata,
$upload_data);
$filelink = $result['filelink'];
return $filelink;
} | [
"public",
"function",
"upload",
"(",
"$",
"filepath",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filepath",
")",
")",
"{",
"throw",
"new",
"FilestackException",
"(",
"\"File not found\"",
",",
"400",
")",
";... | Upload a file to desired cloud service, defaults to Filestack's S3
storage.
@param string $filepath path to file
@param array $options location: specify location, possible
values are:
S3, gcs, azure, rackspace, dropbox
filename: explicitly set the filename
to store as
mimetype: explicitly set the mimetype
intelligent: set to true to use the
Intelligent Ingestion flow
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack\Filelink or file content | [
"Upload",
"a",
"file",
"to",
"desired",
"cloud",
"service",
"defaults",
"to",
"Filestack",
"s",
"S3",
"storage",
"."
] | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/FilestackClient.php#L664-L711 |
41,073 | filestack/filestack-php | filestack/FilestackClient.php | FilestackClient.zip | public function zip($sources, $store_options = [])
{
$transform_tasks = [
'zip' => []
];
if (!empty($store_options)) {
$transform_tasks['store'] = $store_options;
}
$sources_str = '[' . implode(',', $sources) . ']';
// call TransformationMixin
$result = $this->sendTransform($sources_str, $transform_tasks, $this->security);
return $result;
} | php | public function zip($sources, $store_options = [])
{
$transform_tasks = [
'zip' => []
];
if (!empty($store_options)) {
$transform_tasks['store'] = $store_options;
}
$sources_str = '[' . implode(',', $sources) . ']';
// call TransformationMixin
$result = $this->sendTransform($sources_str, $transform_tasks, $this->security);
return $result;
} | [
"public",
"function",
"zip",
"(",
"$",
"sources",
",",
"$",
"store_options",
"=",
"[",
"]",
")",
"{",
"$",
"transform_tasks",
"=",
"[",
"'zip'",
"=>",
"[",
"]",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"store_options",
")",
")",
"{",
"$",
"tr... | Bundle an array of files into a zip file. This task takes the file or files
that are passed in the array and compresses them into a zip file. Sources can
be handles, urls, or a mix of both
@param array $sources Filestack handles and urls to zip
@param array $store_options Optional store options
@throws FilestackException if API call fails, e.g 404 file not found
@return Filestack/Filelink or file content | [
"Bundle",
"an",
"array",
"of",
"files",
"into",
"a",
"zip",
"file",
".",
"This",
"task",
"takes",
"the",
"file",
"or",
"files",
"that",
"are",
"passed",
"in",
"the",
"array",
"and",
"compresses",
"them",
"into",
"a",
"zip",
"file",
".",
"Sources",
"can... | 5396650b246969fec929fdd2c6ab908adb5b28e2 | https://github.com/filestack/filestack-php/blob/5396650b246969fec929fdd2c6ab908adb5b28e2/filestack/FilestackClient.php#L784-L799 |
41,074 | proj4php/proj4php | src/projCode/Aea.php | Aea.phi1z | public function phi1z($eccent, $qs)
{
$phi = Common::asinz(0.5 * $qs);
if ($eccent < Common::EPSLN) {
return $phi;
}
$eccnts = $eccent * $eccent;
for ($i = 1; $i <= 25; ++$i) {
$sinphi = sin($phi);
$cosphi = cos($phi);
$con = $eccent * $sinphi;
$com = 1.0 - $con * $con;
$dphi = 0.5 * $com * $com / $cosphi * ($qs / (1.0 - $eccnts) - $sinphi / $com + 0.5 / $eccent * log((1.0 - $con) / (1.0 + $con)));
$phi = $phi + $dphi;
if (abs($dphi) <= 1e-7) {
return $phi;
}
}
Proj4php::reportError("aea:phi1z:Convergence error");
return null;
} | php | public function phi1z($eccent, $qs)
{
$phi = Common::asinz(0.5 * $qs);
if ($eccent < Common::EPSLN) {
return $phi;
}
$eccnts = $eccent * $eccent;
for ($i = 1; $i <= 25; ++$i) {
$sinphi = sin($phi);
$cosphi = cos($phi);
$con = $eccent * $sinphi;
$com = 1.0 - $con * $con;
$dphi = 0.5 * $com * $com / $cosphi * ($qs / (1.0 - $eccnts) - $sinphi / $com + 0.5 / $eccent * log((1.0 - $con) / (1.0 + $con)));
$phi = $phi + $dphi;
if (abs($dphi) <= 1e-7) {
return $phi;
}
}
Proj4php::reportError("aea:phi1z:Convergence error");
return null;
} | [
"public",
"function",
"phi1z",
"(",
"$",
"eccent",
",",
"$",
"qs",
")",
"{",
"$",
"phi",
"=",
"Common",
"::",
"asinz",
"(",
"0.5",
"*",
"$",
"qs",
")",
";",
"if",
"(",
"$",
"eccent",
"<",
"Common",
"::",
"EPSLN",
")",
"{",
"return",
"$",
"phi",... | Function to compute phi1, the latitude for the inverse of the Albers Conical Equal-Area projection.
@param float $eccent
@param float $qs
@return float|null on Convergence error | [
"Function",
"to",
"compute",
"phi1",
"the",
"latitude",
"for",
"the",
"inverse",
"of",
"the",
"Albers",
"Conical",
"Equal",
"-",
"Area",
"projection",
"."
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/projCode/Aea.php#L198-L224 |
41,075 | proj4php/proj4php | src/Wkt.php | Wkt.applyWKTUtmFromTmerc | protected static function applyWKTUtmFromTmerc() {
// 'UTM Zone 15',
// WGS_1984_UTM_Zone_17N,
// 'Lao_1997_UTM_48N'
// 'UTM Zone 13, Southern Hemisphere'
// 'Hito XVIII 1963 / UTM zone 19S'
// 'ETRS89 / ETRS-TM26' EPSG:3038 (UTM 26)
$srsCode = strtolower(str_replace('_', ' ', $wktParams->srsCode));
if (strpos($srsCode, "utm zone ") !== false || strpos($srsCode, "lao 1997 utm ") !== false || strpos($srsCode, "etrs-tm") !== false) {
$srsCode = str_replace('-tm', '-tm ', $srsCode); //'ETRS89 / ETRS-TM26' ie: EPSG:3038 (UTM 26)
$zoneStr = substr($srsCode, strrpos($srsCode, ' ') + 1);
$zlen = strlen($zoneStr);
if ($zoneStr{$zlen - 1} == 'n') {
$zoneStr = substr($zoneStr, 0, -1);
} elseif ($zoneStr{$zlen - 1} == 's') {
// EPSG:2084 has Hito XVIII 1963 / UTM zone 19S
$zoneStr = substr($zoneStr, 0, -1);
$wktParams->utmSouth = true;
}
$wktParams->zone = intval($zoneStr, 10);
$wktParams->projName = "utm";
if (!isset($wktParams->utmSouth)) {
$wktParams->utmSouth = false;
}
}
} | php | protected static function applyWKTUtmFromTmerc() {
// 'UTM Zone 15',
// WGS_1984_UTM_Zone_17N,
// 'Lao_1997_UTM_48N'
// 'UTM Zone 13, Southern Hemisphere'
// 'Hito XVIII 1963 / UTM zone 19S'
// 'ETRS89 / ETRS-TM26' EPSG:3038 (UTM 26)
$srsCode = strtolower(str_replace('_', ' ', $wktParams->srsCode));
if (strpos($srsCode, "utm zone ") !== false || strpos($srsCode, "lao 1997 utm ") !== false || strpos($srsCode, "etrs-tm") !== false) {
$srsCode = str_replace('-tm', '-tm ', $srsCode); //'ETRS89 / ETRS-TM26' ie: EPSG:3038 (UTM 26)
$zoneStr = substr($srsCode, strrpos($srsCode, ' ') + 1);
$zlen = strlen($zoneStr);
if ($zoneStr{$zlen - 1} == 'n') {
$zoneStr = substr($zoneStr, 0, -1);
} elseif ($zoneStr{$zlen - 1} == 's') {
// EPSG:2084 has Hito XVIII 1963 / UTM zone 19S
$zoneStr = substr($zoneStr, 0, -1);
$wktParams->utmSouth = true;
}
$wktParams->zone = intval($zoneStr, 10);
$wktParams->projName = "utm";
if (!isset($wktParams->utmSouth)) {
$wktParams->utmSouth = false;
}
}
} | [
"protected",
"static",
"function",
"applyWKTUtmFromTmerc",
"(",
")",
"{",
"// 'UTM Zone 15',",
"// WGS_1984_UTM_Zone_17N,",
"// 'Lao_1997_UTM_48N'",
"// 'UTM Zone 13, Southern Hemisphere'",
"// 'Hito XVIII 1963 / UTM zone 19S'",
"// 'ETRS89 / ETRS-TM26' EPSG:3038 (UTM 26)",
"$",
"srsCod... | convert from tmerc to utm+zone after parseWkt
@return [type] [description] | [
"convert",
"from",
"tmerc",
"to",
"utm",
"+",
"zone",
"after",
"parseWkt"
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/Wkt.php#L443-L470 |
41,076 | proj4php/proj4php | src/Datum.php | Datum.geocentric_to_geodetic_noniter | public function geocentric_to_geodetic_noniter(Point $p)
{
/*
$Longitude;
$Latitude;
$Height;
$W; // distance from Z axis
$W2; // square of distance from Z axis
$T0; // initial estimate of vertical component
$T1; // corrected estimate of vertical component
$S0; // initial estimate of horizontal component
$S1; // corrected estimate of horizontal component
$Sin_B0; // sin(B0), B0 is estimate of Bowring aux variable
$Sin3_B0; // cube of sin(B0)
$Cos_B0; // cos(B0)
$Sin_p1; // sin(phi1), phi1 is estimated latitude
$Cos_p1; // cos(phi1)
$Rn; // Earth radius at location
$Sum; // numerator of cos(phi1)
$AtPole; // indicates location is in polar region
*/
// Cast from string to float.
// Since we are accepting the Point class only, then we can already
// guarantee we have floats. A simple list($x, $y $Z) = $p->toArray() will
// give us our values.
$X = floatval($p->x);
$Y = floatval($p->y);
$Z = floatval($p->z ? $p->z : 0);
$AtPole = false;
if ($X <> 0.0) {
$Longitude = atan2($Y, $X);
} else {
if ($Y > 0) {
$Longitude = Common::HALF_PI;
} elseif (Y < 0) {
$Longitude = -Common::HALF_PI;
} else {
$AtPole = true;
$Longitude = 0.0;
if ($Z > 0.0) { /* north pole */
$Latitude = Common::HALF_PI;
} elseif (Z < 0.0) { /* south pole */
$Latitude = -Common::HALF_PI;
} else { /* center of earth */
$Latitude = Common::HALF_PI;
$Height = -$this->b;
return;
}
}
}
$W2 = $X * $X + $Y * $Y;
$W = sqrt($W2);
$T0 = $Z * Common::AD_C;
$S0 = sqrt($T0 * $T0 + $W2);
$Sin_B0 = $T0 / $S0;
$Cos_B0 = $W / $S0;
$Sin3_B0 = $Sin_B0 * $Sin_B0 * $Sin_B0;
$T1 = $Z + $this->b * $this->ep2 * $Sin3_B0;
$Sum = $W - $this->a * $this->es * $Cos_B0 * $Cos_B0 * $Cos_B0;
$S1 = sqrt($T1 * $T1 + $Sum * $Sum);
$Sin_p1 = $T1 / $S1;
$Cos_p1 = $Sum / $S1;
$Rn = $this->a / sqrt( 1.0 - $this->es * $Sin_p1 * $Sin_p1);
if ($Cos_p1 >= Common::COS_67P5) {
$Height = $W / $Cos_p1 - $Rn;
} elseif ($Cos_p1 <= -Common::COS_67P5) {
$Height = $W / -$Cos_p1 - $Rn;
} else {
$Height = $Z / $Sin_p1 + $Rn * ($this->es - 1.0);
}
if ($AtPole == false) {
$Latitude = atan($Sin_p1 / $Cos_p1);
}
$p->x = $Longitude;
$p->y = $Latitude;
$p->z = $Height;
return $p;
} | php | public function geocentric_to_geodetic_noniter(Point $p)
{
/*
$Longitude;
$Latitude;
$Height;
$W; // distance from Z axis
$W2; // square of distance from Z axis
$T0; // initial estimate of vertical component
$T1; // corrected estimate of vertical component
$S0; // initial estimate of horizontal component
$S1; // corrected estimate of horizontal component
$Sin_B0; // sin(B0), B0 is estimate of Bowring aux variable
$Sin3_B0; // cube of sin(B0)
$Cos_B0; // cos(B0)
$Sin_p1; // sin(phi1), phi1 is estimated latitude
$Cos_p1; // cos(phi1)
$Rn; // Earth radius at location
$Sum; // numerator of cos(phi1)
$AtPole; // indicates location is in polar region
*/
// Cast from string to float.
// Since we are accepting the Point class only, then we can already
// guarantee we have floats. A simple list($x, $y $Z) = $p->toArray() will
// give us our values.
$X = floatval($p->x);
$Y = floatval($p->y);
$Z = floatval($p->z ? $p->z : 0);
$AtPole = false;
if ($X <> 0.0) {
$Longitude = atan2($Y, $X);
} else {
if ($Y > 0) {
$Longitude = Common::HALF_PI;
} elseif (Y < 0) {
$Longitude = -Common::HALF_PI;
} else {
$AtPole = true;
$Longitude = 0.0;
if ($Z > 0.0) { /* north pole */
$Latitude = Common::HALF_PI;
} elseif (Z < 0.0) { /* south pole */
$Latitude = -Common::HALF_PI;
} else { /* center of earth */
$Latitude = Common::HALF_PI;
$Height = -$this->b;
return;
}
}
}
$W2 = $X * $X + $Y * $Y;
$W = sqrt($W2);
$T0 = $Z * Common::AD_C;
$S0 = sqrt($T0 * $T0 + $W2);
$Sin_B0 = $T0 / $S0;
$Cos_B0 = $W / $S0;
$Sin3_B0 = $Sin_B0 * $Sin_B0 * $Sin_B0;
$T1 = $Z + $this->b * $this->ep2 * $Sin3_B0;
$Sum = $W - $this->a * $this->es * $Cos_B0 * $Cos_B0 * $Cos_B0;
$S1 = sqrt($T1 * $T1 + $Sum * $Sum);
$Sin_p1 = $T1 / $S1;
$Cos_p1 = $Sum / $S1;
$Rn = $this->a / sqrt( 1.0 - $this->es * $Sin_p1 * $Sin_p1);
if ($Cos_p1 >= Common::COS_67P5) {
$Height = $W / $Cos_p1 - $Rn;
} elseif ($Cos_p1 <= -Common::COS_67P5) {
$Height = $W / -$Cos_p1 - $Rn;
} else {
$Height = $Z / $Sin_p1 + $Rn * ($this->es - 1.0);
}
if ($AtPole == false) {
$Latitude = atan($Sin_p1 / $Cos_p1);
}
$p->x = $Longitude;
$p->y = $Latitude;
$p->z = $Height;
return $p;
} | [
"public",
"function",
"geocentric_to_geodetic_noniter",
"(",
"Point",
"$",
"p",
")",
"{",
"/*\r\n $Longitude;\r\n $Latitude;\r\n $Height;\r\n\r\n $W; // distance from Z axis \r\n $W2; // square of distance from Z axis \r\n $T0; // initia... | Convert_Geocentric_To_Geodetic
The method used here is derived from 'An Improved Algorithm for
Geocentric to Geodetic Coordinate Conversion', by Ralph Toms, Feb 1996
@param object Point $p
@return object Point $p | [
"Convert_Geocentric_To_Geodetic",
"The",
"method",
"used",
"here",
"is",
"derived",
"from",
"An",
"Improved",
"Algorithm",
"for",
"Geocentric",
"to",
"Geodetic",
"Coordinate",
"Conversion",
"by",
"Ralph",
"Toms",
"Feb",
"1996"
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/Datum.php#L338-L425 |
41,077 | proj4php/proj4php | src/projCode/Sinu.php | Sinu.init | public function init()
{
// Place parameters in static storage for common use
#$this->R = 6370997.0; //Radius of earth
if (isset($this->sphere)) {
//fixes SR-ORG:6965
$this->en = Common::pj_enfn( $this->es );
} else {
$this->n = 1.;
$this->m = 0.;
$this->es = 0;
$this->C_y = sqrt( ($this->m + 1.) / $this->n );
$this->C_x = $this->C_y / ($this->m + 1.);
}
} | php | public function init()
{
// Place parameters in static storage for common use
#$this->R = 6370997.0; //Radius of earth
if (isset($this->sphere)) {
//fixes SR-ORG:6965
$this->en = Common::pj_enfn( $this->es );
} else {
$this->n = 1.;
$this->m = 0.;
$this->es = 0;
$this->C_y = sqrt( ($this->m + 1.) / $this->n );
$this->C_x = $this->C_y / ($this->m + 1.);
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"// Place parameters in static storage for common use\r",
"#$this->R = 6370997.0; //Radius of earth\r",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"sphere",
")",
")",
"{",
"//fixes SR-ORG:6965\r",
"$",
"this",
"->",
"en",
... | Initialize the Sinusoidal projection | [
"Initialize",
"the",
"Sinusoidal",
"projection"
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/projCode/Sinu.php#L58-L73 |
41,078 | proj4php/proj4php | src/projCode/Tmerc.php | Tmerc.init | public function init()
{
if (! isset($this->lat0)){
// SR-ORG:6696 does not define lat0 param in wkt
$this->lat0=0.0;
}
$this->e0 = Common::e0fn( $this->es );
$this->e1 = Common::e1fn( $this->es );
$this->e2 = Common::e2fn( $this->es );
$this->e3 = Common::e3fn( $this->es );
$this->ml0 = $this->a * Common::mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat0 );
} | php | public function init()
{
if (! isset($this->lat0)){
// SR-ORG:6696 does not define lat0 param in wkt
$this->lat0=0.0;
}
$this->e0 = Common::e0fn( $this->es );
$this->e1 = Common::e1fn( $this->es );
$this->e2 = Common::e2fn( $this->es );
$this->e3 = Common::e3fn( $this->es );
$this->ml0 = $this->a * Common::mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat0 );
} | [
"public",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"lat0",
")",
")",
"{",
"// SR-ORG:6696 does not define lat0 param in wkt\r",
"$",
"this",
"->",
"lat0",
"=",
"0.0",
";",
"}",
"$",
"this",
"->",
"e0",
"=",
"C... | Initialize Transverse Mercator projection | [
"Initialize",
"Transverse",
"Mercator",
"projection"
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/projCode/Tmerc.php#L51-L64 |
41,079 | proj4php/proj4php | src/Point.php | Point.__isset | public function __isset($name)
{
$name = strtolower($name);
if ($name != 'x' && $name != 'y' && $name != 'z') {
return false;
}
return isset($this->$name);
} | php | public function __isset($name)
{
$name = strtolower($name);
if ($name != 'x' && $name != 'y' && $name != 'z') {
return false;
}
return isset($this->$name);
} | [
"public",
"function",
"__isset",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"name",
"!=",
"'x'",
"&&",
"$",
"name",
"!=",
"'y'",
"&&",
"$",
"name",
"!=",
"'z'",
")",
"{",
"return",
"f... | Setter for x, y and z. | [
"Setter",
"for",
"x",
"y",
"and",
"z",
"."
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/Point.php#L151-L160 |
41,080 | proj4php/proj4php | src/projCode/Poly.php | Poly.phi4z | protected function phi4z($eccent, $e0, $e1, $e2, $e3, $a, $b, &$c, $phi)
{
/*
$sinphi;
$sin2ph;
$tanph;
$ml;
$mlp;
$con1;
$con2;
$con3;
$dphi;
$i;
*/
$phi = $a;
for ($i = 1; $i <= 15; $i++) {
$sinphi = sin( $phi );
$tanphi = tan( $phi );
$c = $tanphi * sqrt( 1.0 - $eccent * $sinphi * $sinphi );
$sin2ph = sin( 2.0 * $phi );
/*
ml = e0 * *phi - e1 * sin2ph + e2 * sin (4.0 * *phi);
mlp = e0 - 2.0 * e1 * cos (2.0 * *phi) + 4.0 * e2 * cos (4.0 * *phi);
*/
$ml = $e0 * $phi - $e1 * $sin2ph + $e2 * sin( 4.0 * $phi ) - $e3 * sin( 6.0 * $phi );
$mlp = $e0 - 2.0 * $e1 * cos( 2.0 * $phi ) + 4.0 * $e2 * cos( 4.0 * $phi ) - 6.0 * $e3 * cos( 6.0 * $phi );
$con1 = 2.0 * $ml + $c * ($ml * $ml + $b) - 2.0 * $a * ($c * $ml + 1.0);
$con2 = $eccent * $sin2ph * ($ml * $ml + $b - 2.0 * $a * $ml) / (2.0 * $c);
$con3 = 2.0 * ($a - $ml) * ($c * $mlp - 2.0 / $sin2ph) - 2.0 * $mlp;
$dphi = $con1 / ($con2 + $con3);
$phi += $dphi;
if ( abs( $dphi ) <= .0000000001 ) {
return($phi);
}
}
Proj4php::reportError('phi4z: No convergence');
return null;
} | php | protected function phi4z($eccent, $e0, $e1, $e2, $e3, $a, $b, &$c, $phi)
{
/*
$sinphi;
$sin2ph;
$tanph;
$ml;
$mlp;
$con1;
$con2;
$con3;
$dphi;
$i;
*/
$phi = $a;
for ($i = 1; $i <= 15; $i++) {
$sinphi = sin( $phi );
$tanphi = tan( $phi );
$c = $tanphi * sqrt( 1.0 - $eccent * $sinphi * $sinphi );
$sin2ph = sin( 2.0 * $phi );
/*
ml = e0 * *phi - e1 * sin2ph + e2 * sin (4.0 * *phi);
mlp = e0 - 2.0 * e1 * cos (2.0 * *phi) + 4.0 * e2 * cos (4.0 * *phi);
*/
$ml = $e0 * $phi - $e1 * $sin2ph + $e2 * sin( 4.0 * $phi ) - $e3 * sin( 6.0 * $phi );
$mlp = $e0 - 2.0 * $e1 * cos( 2.0 * $phi ) + 4.0 * $e2 * cos( 4.0 * $phi ) - 6.0 * $e3 * cos( 6.0 * $phi );
$con1 = 2.0 * $ml + $c * ($ml * $ml + $b) - 2.0 * $a * ($c * $ml + 1.0);
$con2 = $eccent * $sin2ph * ($ml * $ml + $b - 2.0 * $a * $ml) / (2.0 * $c);
$con3 = 2.0 * ($a - $ml) * ($c * $mlp - 2.0 / $sin2ph) - 2.0 * $mlp;
$dphi = $con1 / ($con2 + $con3);
$phi += $dphi;
if ( abs( $dphi ) <= .0000000001 ) {
return($phi);
}
}
Proj4php::reportError('phi4z: No convergence');
return null;
} | [
"protected",
"function",
"phi4z",
"(",
"$",
"eccent",
",",
"$",
"e0",
",",
"$",
"e1",
",",
"$",
"e2",
",",
"$",
"e3",
",",
"$",
"a",
",",
"$",
"b",
",",
"&",
"$",
"c",
",",
"$",
"phi",
")",
"{",
"/*\r\n $sinphi;\r\n $sin2ph;\r\n ... | Compute, phi4, the latitude for the inverse of the
Polyconic projection. | [
"Compute",
"phi4",
"the",
"latitude",
"for",
"the",
"inverse",
"of",
"the",
"Polyconic",
"projection",
"."
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/projCode/Poly.php#L63-L104 |
41,081 | proj4php/proj4php | src/projCode/Poly.php | Poly.e4fn | function e4fn($x)
{
#$con;
#$com;
$con = 1.0 + $x;
$com = 1.0 - $x;
return (sqrt( (pow( $con, $con )) * (pow( $com, $com )) ));
} | php | function e4fn($x)
{
#$con;
#$com;
$con = 1.0 + $x;
$com = 1.0 - $x;
return (sqrt( (pow( $con, $con )) * (pow( $com, $com )) ));
} | [
"function",
"e4fn",
"(",
"$",
"x",
")",
"{",
"#$con;\r",
"#$com;\r",
"$",
"con",
"=",
"1.0",
"+",
"$",
"x",
";",
"$",
"com",
"=",
"1.0",
"-",
"$",
"x",
";",
"return",
"(",
"sqrt",
"(",
"(",
"pow",
"(",
"$",
"con",
",",
"$",
"con",
")",
")",... | Compute the constant e4 from the input of the eccentricity
of the spheroid, x. This constant is used in the Polar Stereographic
projection. | [
"Compute",
"the",
"constant",
"e4",
"from",
"the",
"input",
"of",
"the",
"eccentricity",
"of",
"the",
"spheroid",
"x",
".",
"This",
"constant",
"is",
"used",
"in",
"the",
"Polar",
"Stereographic",
"projection",
"."
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/projCode/Poly.php#L111-L118 |
41,082 | proj4php/proj4php | src/projCode/Poly.php | Poly.init | public function init()
{
if ( $this->lat0 == 0 ) {
$this->lat0 = 90; //$this->lat0 ca
}
/* Place parameters in static storage for common use
------------------------------------------------- */
$this->temp = $this->b / $this->a;
$this->es = 1.0 - pow( $this->temp, 2 ); // devait etre dans tmerc.js mais n y est pas donc je commente sinon retour de valeurs nulles
$this->e = sqrt( $this->es );
$this->e0 = Common::e0fn( $this->es );
$this->e1 = Common::e1fn( $this->es );
$this->e2 = Common::e2fn( $this->es );
$this->e3 = Common::e3fn( $this->es );
$this->ml0 = Common::mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat0 ); //si que des zeros le calcul ne se fait pas
//if (!$this->ml0) {$this->ml0=0;}
} | php | public function init()
{
if ( $this->lat0 == 0 ) {
$this->lat0 = 90; //$this->lat0 ca
}
/* Place parameters in static storage for common use
------------------------------------------------- */
$this->temp = $this->b / $this->a;
$this->es = 1.0 - pow( $this->temp, 2 ); // devait etre dans tmerc.js mais n y est pas donc je commente sinon retour de valeurs nulles
$this->e = sqrt( $this->es );
$this->e0 = Common::e0fn( $this->es );
$this->e1 = Common::e1fn( $this->es );
$this->e2 = Common::e2fn( $this->es );
$this->e3 = Common::e3fn( $this->es );
$this->ml0 = Common::mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat0 ); //si que des zeros le calcul ne se fait pas
//if (!$this->ml0) {$this->ml0=0;}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"lat0",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"lat0",
"=",
"90",
";",
"//$this->lat0 ca\r",
"}",
"/* Place parameters in static storage for common use\r\n -------------------------... | Initialize the POLYCONIC projection | [
"Initialize",
"the",
"POLYCONIC",
"projection"
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/projCode/Poly.php#L123-L140 |
41,083 | proj4php/proj4php | src/Common.php | Common.msfnz | public static function msfnz($eccent, $sinphi, $cosphi)
{
$con = $eccent * $sinphi;
return $cosphi / (sqrt(1.0 - $con * $con));
} | php | public static function msfnz($eccent, $sinphi, $cosphi)
{
$con = $eccent * $sinphi;
return $cosphi / (sqrt(1.0 - $con * $con));
} | [
"public",
"static",
"function",
"msfnz",
"(",
"$",
"eccent",
",",
"$",
"sinphi",
",",
"$",
"cosphi",
")",
"{",
"$",
"con",
"=",
"$",
"eccent",
"*",
"$",
"sinphi",
";",
"return",
"$",
"cosphi",
"/",
"(",
"sqrt",
"(",
"1.0",
"-",
"$",
"con",
"*",
... | Function to compute the constant small m which is the radius of
a parallel of latitude, phi, divided by the semimajor axis.
@param float $eccent
@param float $sinphi
@param float $cosphi
@return float | [
"Function",
"to",
"compute",
"the",
"constant",
"small",
"m",
"which",
"is",
"the",
"radius",
"of",
"a",
"parallel",
"of",
"latitude",
"phi",
"divided",
"by",
"the",
"semimajor",
"axis",
"."
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/Common.php#L86-L90 |
41,084 | proj4php/proj4php | src/Common.php | Common.tsfnz | public static function tsfnz($eccent, $phi, $sinphi)
{
$con = $eccent * $sinphi;
$com = 0.5 * $eccent;
$con = pow(((1.0 - $con) / (1.0 + $con)), $com);
return (tan(0.5 * (M_PI_2 - $phi) ) / $con);
} | php | public static function tsfnz($eccent, $phi, $sinphi)
{
$con = $eccent * $sinphi;
$com = 0.5 * $eccent;
$con = pow(((1.0 - $con) / (1.0 + $con)), $com);
return (tan(0.5 * (M_PI_2 - $phi) ) / $con);
} | [
"public",
"static",
"function",
"tsfnz",
"(",
"$",
"eccent",
",",
"$",
"phi",
",",
"$",
"sinphi",
")",
"{",
"$",
"con",
"=",
"$",
"eccent",
"*",
"$",
"sinphi",
";",
"$",
"com",
"=",
"0.5",
"*",
"$",
"eccent",
";",
"$",
"con",
"=",
"pow",
"(",
... | Function to compute the constant small t for use in the forward
computations in the Lambert Conformal Conic and the Polar
Stereographic projections.
@param float $eccent
@param float $phi
@param float $sinphi
@return float | [
"Function",
"to",
"compute",
"the",
"constant",
"small",
"t",
"for",
"use",
"in",
"the",
"forward",
"computations",
"in",
"the",
"Lambert",
"Conformal",
"Conic",
"and",
"the",
"Polar",
"Stereographic",
"projections",
"."
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/Common.php#L102-L109 |
41,085 | proj4php/proj4php | src/Common.php | Common.phi2z | public static function phi2z($eccent, $ts)
{
$eccnth = 0.5 * $eccent;
$phi = M_PI_2 - 2 * atan($ts);
for ($i = 0; $i <= 15; $i++) {
$con = $eccent * sin($phi);
$dphi = M_PI_2
- 2 * atan($ts * (pow(((1.0 - $con) / (1.0 + $con)), $eccnth )))
- $phi;
$phi += $dphi;
if (abs($dphi) <= .0000000001) {
return $phi;
}
}
assert("false; /* phi2z has NoConvergence */");
// What does this return value mean?
return (-9999);
} | php | public static function phi2z($eccent, $ts)
{
$eccnth = 0.5 * $eccent;
$phi = M_PI_2 - 2 * atan($ts);
for ($i = 0; $i <= 15; $i++) {
$con = $eccent * sin($phi);
$dphi = M_PI_2
- 2 * atan($ts * (pow(((1.0 - $con) / (1.0 + $con)), $eccnth )))
- $phi;
$phi += $dphi;
if (abs($dphi) <= .0000000001) {
return $phi;
}
}
assert("false; /* phi2z has NoConvergence */");
// What does this return value mean?
return (-9999);
} | [
"public",
"static",
"function",
"phi2z",
"(",
"$",
"eccent",
",",
"$",
"ts",
")",
"{",
"$",
"eccnth",
"=",
"0.5",
"*",
"$",
"eccent",
";",
"$",
"phi",
"=",
"M_PI_2",
"-",
"2",
"*",
"atan",
"(",
"$",
"ts",
")",
";",
"for",
"(",
"$",
"i",
"=",
... | Function to compute the latitude angle, phi2, for the inverse of the
Lambert Conformal Conic and Polar Stereographic projections.
rise up an assertion if there is no convergence.
@param float $eccent
@param float $ts
@return float|int | [
"Function",
"to",
"compute",
"the",
"latitude",
"angle",
"phi2",
"for",
"the",
"inverse",
"of",
"the",
"Lambert",
"Conformal",
"Conic",
"and",
"Polar",
"Stereographic",
"projections",
"."
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/Common.php#L121-L142 |
41,086 | proj4php/proj4php | src/Common.php | Common.qsfnz | public static function qsfnz($eccent, $sinphi)
{
if ($eccent > 1.0e-7) {
$con = $eccent * $sinphi;
return (
( 1.0 - $eccent * $eccent)
* ($sinphi / (1.0 - $con * $con) - (.5 / $eccent) * log( (1.0 - $con) / (1.0 + $con) ))
);
}
return (2.0 * $sinphi);
} | php | public static function qsfnz($eccent, $sinphi)
{
if ($eccent > 1.0e-7) {
$con = $eccent * $sinphi;
return (
( 1.0 - $eccent * $eccent)
* ($sinphi / (1.0 - $con * $con) - (.5 / $eccent) * log( (1.0 - $con) / (1.0 + $con) ))
);
}
return (2.0 * $sinphi);
} | [
"public",
"static",
"function",
"qsfnz",
"(",
"$",
"eccent",
",",
"$",
"sinphi",
")",
"{",
"if",
"(",
"$",
"eccent",
">",
"1.0e-7",
")",
"{",
"$",
"con",
"=",
"$",
"eccent",
"*",
"$",
"sinphi",
";",
"return",
"(",
"(",
"1.0",
"-",
"$",
"eccent",
... | Function to compute constant small q which is the radius of a
parallel of latitude, phi, divided by the semimajor axis.
@param float $eccent
@param float $sinphi
@return float | [
"Function",
"to",
"compute",
"constant",
"small",
"q",
"which",
"is",
"the",
"radius",
"of",
"a",
"parallel",
"of",
"latitude",
"phi",
"divided",
"by",
"the",
"semimajor",
"axis",
"."
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/Common.php#L152-L164 |
41,087 | proj4php/proj4php | src/Common.php | Common.adjust_lon | public static function adjust_lon($x)
{
return (abs($x) < M_PI)
? $x
: ($x - (static::sign($x) * static::TWO_PI));
} | php | public static function adjust_lon($x)
{
return (abs($x) < M_PI)
? $x
: ($x - (static::sign($x) * static::TWO_PI));
} | [
"public",
"static",
"function",
"adjust_lon",
"(",
"$",
"x",
")",
"{",
"return",
"(",
"abs",
"(",
"$",
"x",
")",
"<",
"M_PI",
")",
"?",
"$",
"x",
":",
"(",
"$",
"x",
"-",
"(",
"static",
"::",
"sign",
"(",
"$",
"x",
")",
"*",
"static",
"::",
... | Adjust longitude to -180 to 180; input in radians
@param float $x
@return float | [
"Adjust",
"longitude",
"to",
"-",
"180",
"to",
"180",
";",
"input",
"in",
"radians"
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/Common.php#L263-L268 |
41,088 | proj4php/proj4php | src/Common.php | Common.latiso | public static function latiso($eccent, $phi, $sinphi)
{
if (abs($phi) > M_PI_2) {
return +NaN;
}
if ($phi == M_PI_2) {
return INF;
}
if ($phi == -1.0 * M_PI_2) {
return -1.0 * INF;
}
$con = $eccent * $sinphi;
return log(tan((M_PI_2 + $phi) / 2.0 ) )
+ $eccent * log( (1.0 - $con) / (1.0 + $con)) / 2.0;
} | php | public static function latiso($eccent, $phi, $sinphi)
{
if (abs($phi) > M_PI_2) {
return +NaN;
}
if ($phi == M_PI_2) {
return INF;
}
if ($phi == -1.0 * M_PI_2) {
return -1.0 * INF;
}
$con = $eccent * $sinphi;
return log(tan((M_PI_2 + $phi) / 2.0 ) )
+ $eccent * log( (1.0 - $con) / (1.0 + $con)) / 2.0;
} | [
"public",
"static",
"function",
"latiso",
"(",
"$",
"eccent",
",",
"$",
"phi",
",",
"$",
"sinphi",
")",
"{",
"if",
"(",
"abs",
"(",
"$",
"phi",
")",
">",
"M_PI_2",
")",
"{",
"return",
"+",
"NaN",
";",
"}",
"if",
"(",
"$",
"phi",
"==",
"M_PI_2",... | Latitude Isometrique - close to tsfnz ...
@param float $eccent
@param float $phi
@param float $sinphi
@return float | [
"Latitude",
"Isometrique",
"-",
"close",
"to",
"tsfnz",
"..."
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/Common.php#L294-L312 |
41,089 | proj4php/proj4php | src/Common.php | Common.invlatiso | public static function invlatiso($eccent, $ts)
{
$phi = static::fL(1.0, $ts);
$Iphi = 0.0;
$con = 0.0;
do {
$Iphi = $phi;
$con = $eccent * sin($Iphi);
$phi = static::fL(exp($eccent * log((1.0 + $con) / (1.0 - $con)) / 2.0 ), $ts);
} while(abs($phi - $Iphi) > 1.0e-12);
return $phi;
} | php | public static function invlatiso($eccent, $ts)
{
$phi = static::fL(1.0, $ts);
$Iphi = 0.0;
$con = 0.0;
do {
$Iphi = $phi;
$con = $eccent * sin($Iphi);
$phi = static::fL(exp($eccent * log((1.0 + $con) / (1.0 - $con)) / 2.0 ), $ts);
} while(abs($phi - $Iphi) > 1.0e-12);
return $phi;
} | [
"public",
"static",
"function",
"invlatiso",
"(",
"$",
"eccent",
",",
"$",
"ts",
")",
"{",
"$",
"phi",
"=",
"static",
"::",
"fL",
"(",
"1.0",
",",
"$",
"ts",
")",
";",
"$",
"Iphi",
"=",
"0.0",
";",
"$",
"con",
"=",
"0.0",
";",
"do",
"{",
"$",... | Inverse Latitude Isometrique - close to ph2z
@param float $eccent
@param float $ts
@return float | [
"Inverse",
"Latitude",
"Isometrique",
"-",
"close",
"to",
"ph2z"
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/Common.php#L332-L345 |
41,090 | proj4php/proj4php | src/Common.php | Common.pj_enfn | public static function pj_enfn($es)
{
$en = array();
$en[0] = static::C00 - $es * (static::C02 + $es * (static::C04 + $es * (static::C06 + $es * static::C08)));
$en[1] = $es * (static::C22 - $es * (static::C04 + $es * (static::C06 + $es * static::C08)));
$t = $es * $es;
$en[2] = $t * (static::C44 - $es * (static::C46 + $es * static::C48));
$t *= $es;
$en[3] = $t * (static::C66 - $es * static::C68);
$en[4] = $t * $es * static::C88;
return $en;
} | php | public static function pj_enfn($es)
{
$en = array();
$en[0] = static::C00 - $es * (static::C02 + $es * (static::C04 + $es * (static::C06 + $es * static::C08)));
$en[1] = $es * (static::C22 - $es * (static::C04 + $es * (static::C06 + $es * static::C08)));
$t = $es * $es;
$en[2] = $t * (static::C44 - $es * (static::C46 + $es * static::C48));
$t *= $es;
$en[3] = $t * (static::C66 - $es * static::C68);
$en[4] = $t * $es * static::C88;
return $en;
} | [
"public",
"static",
"function",
"pj_enfn",
"(",
"$",
"es",
")",
"{",
"$",
"en",
"=",
"array",
"(",
")",
";",
"$",
"en",
"[",
"0",
"]",
"=",
"static",
"::",
"C00",
"-",
"$",
"es",
"*",
"(",
"static",
"::",
"C02",
"+",
"$",
"es",
"*",
"(",
"s... | code from the PROJ.4 pj_mlfn.c file; this may be useful for other projections
@param float $es
@return float | [
"code",
"from",
"the",
"PROJ",
".",
"4",
"pj_mlfn",
".",
"c",
"file",
";",
"this",
"may",
"be",
"useful",
"for",
"other",
"projections"
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/Common.php#L367-L379 |
41,091 | proj4php/proj4php | src/projCode/Ortho.php | Ortho.init | public function init()
{
//SR-ORG:6980
//double temp;
// Place parameters in static storage for common use
$this->sin_p14 = sin($this->lat0);
$this->cos_p14 = cos($this->lat0);
} | php | public function init()
{
//SR-ORG:6980
//double temp;
// Place parameters in static storage for common use
$this->sin_p14 = sin($this->lat0);
$this->cos_p14 = cos($this->lat0);
} | [
"public",
"function",
"init",
"(",
")",
"{",
"//SR-ORG:6980\r",
"//double temp;\r",
"// Place parameters in static storage for common use\r",
"$",
"this",
"->",
"sin_p14",
"=",
"sin",
"(",
"$",
"this",
"->",
"lat0",
")",
";",
"$",
"this",
"->",
"cos_p14",
"=",
"... | Initialize the Orthographic projection | [
"Initialize",
"the",
"Orthographic",
"projection"
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/projCode/Ortho.php#L52-L61 |
41,092 | proj4php/proj4php | src/projCode/Gnom.php | Gnom.init | public function init($def = null)
{
// Place parameters in static storage for common use
$this->sin_p14 = sin( $this->lat0 );
$this->cos_p14 = cos( $this->lat0 );
// Approximation for projecting points to the horizon (infinity)
$this->infinity_dist = 1000 * $this->a;
$this->rc = 1;
} | php | public function init($def = null)
{
// Place parameters in static storage for common use
$this->sin_p14 = sin( $this->lat0 );
$this->cos_p14 = cos( $this->lat0 );
// Approximation for projecting points to the horizon (infinity)
$this->infinity_dist = 1000 * $this->a;
$this->rc = 1;
} | [
"public",
"function",
"init",
"(",
"$",
"def",
"=",
"null",
")",
"{",
"// Place parameters in static storage for common use\r",
"$",
"this",
"->",
"sin_p14",
"=",
"sin",
"(",
"$",
"this",
"->",
"lat0",
")",
";",
"$",
"this",
"->",
"cos_p14",
"=",
"cos",
"(... | Initialize the Gnomonic projection
@todo $def not used in context...?
@param mixed $def | [
"Initialize",
"the",
"Gnomonic",
"projection"
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/projCode/Gnom.php#L58-L68 |
41,093 | proj4php/proj4php | src/projCode/Laea.php | Laea.init | public function init()
{
$t = abs($this->lat0);
if (abs( $t - Common::HALF_PI) < Common::EPSLN) {
$this->mode = $this->lat0 < 0. ? $this->S_POLE : $this->N_POLE;
} else if( abs( $t ) < Common::EPSLN ) {
$this->mode = $this->EQUIT;
} else {
$this->mode = $this->OBLIQ;
}
if ($this->es > 0) {
#$sinphi;
$this->qp = Common::qsfnz( $this->e, 1.0 );
$this->mmf = 0.5 / (1.0 - $this->es);
$this->apa = $this->authset( $this->es );
switch( $this->mode ) {
case $this->N_POLE:
case $this->S_POLE:
$this->dd = 1.0;
break;
case $this->EQUIT:
$this->rq = sqrt( .5 * $this->qp );
$this->dd = 1.0 / $this->rq;
$this->xmf = 1.0;
$this->ymf = 0.5 * $this->qp;
break;
case $this->OBLIQ:
$this->rq = sqrt( .5 * $this->qp );
$sinphi = sin( $this->lat0 );
$this->sinb1 = Common::qsfnz( $this->e, $sinphi ) / $this->qp;
$this->cosb1 = sqrt( 1. - $this->sinb1 * $this->sinb1 );
$this->dd = cos( $this->lat0 ) / (sqrt( 1.0 - $this->es * $sinphi * $sinphi ) * $this->rq * $this->cosb1);
$this->ymf = ($this->xmf = $this->rq) / $this->dd;
$this->xmf *= $this->dd;
break;
}
} else {
if ($this->mode == $this->OBLIQ) {
$this->sinph0 = sin($this->lat0);
$this->cosph0 = cos($this->lat0);
}
}
} | php | public function init()
{
$t = abs($this->lat0);
if (abs( $t - Common::HALF_PI) < Common::EPSLN) {
$this->mode = $this->lat0 < 0. ? $this->S_POLE : $this->N_POLE;
} else if( abs( $t ) < Common::EPSLN ) {
$this->mode = $this->EQUIT;
} else {
$this->mode = $this->OBLIQ;
}
if ($this->es > 0) {
#$sinphi;
$this->qp = Common::qsfnz( $this->e, 1.0 );
$this->mmf = 0.5 / (1.0 - $this->es);
$this->apa = $this->authset( $this->es );
switch( $this->mode ) {
case $this->N_POLE:
case $this->S_POLE:
$this->dd = 1.0;
break;
case $this->EQUIT:
$this->rq = sqrt( .5 * $this->qp );
$this->dd = 1.0 / $this->rq;
$this->xmf = 1.0;
$this->ymf = 0.5 * $this->qp;
break;
case $this->OBLIQ:
$this->rq = sqrt( .5 * $this->qp );
$sinphi = sin( $this->lat0 );
$this->sinb1 = Common::qsfnz( $this->e, $sinphi ) / $this->qp;
$this->cosb1 = sqrt( 1. - $this->sinb1 * $this->sinb1 );
$this->dd = cos( $this->lat0 ) / (sqrt( 1.0 - $this->es * $sinphi * $sinphi ) * $this->rq * $this->cosb1);
$this->ymf = ($this->xmf = $this->rq) / $this->dd;
$this->xmf *= $this->dd;
break;
}
} else {
if ($this->mode == $this->OBLIQ) {
$this->sinph0 = sin($this->lat0);
$this->cosph0 = cos($this->lat0);
}
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"t",
"=",
"abs",
"(",
"$",
"this",
"->",
"lat0",
")",
";",
"if",
"(",
"abs",
"(",
"$",
"t",
"-",
"Common",
"::",
"HALF_PI",
")",
"<",
"Common",
"::",
"EPSLN",
")",
"{",
"$",
"this",
"->",
"mod... | Initialize the Lambert Azimuthal Equal Area projection | [
"Initialize",
"the",
"Lambert",
"Azimuthal",
"Equal",
"Area",
"projection"
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/projCode/Laea.php#L83-L127 |
41,094 | proj4php/proj4php | src/projCode/Laea.php | Laea.authset | public function authset($es) {
#$t;
$APA = array();
$APA[0] = $es * $this->P00;
$t = $es * $es;
$APA[0] += $t * $this->P01;
$APA[1] = $t * $this->P10;
$t *= $es;
$APA[0] += $t * $this->P02;
$APA[1] += $t * $this->P11;
$APA[2] = $t * $this->P20;
return $APA;
} | php | public function authset($es) {
#$t;
$APA = array();
$APA[0] = $es * $this->P00;
$t = $es * $es;
$APA[0] += $t * $this->P01;
$APA[1] = $t * $this->P10;
$t *= $es;
$APA[0] += $t * $this->P02;
$APA[1] += $t * $this->P11;
$APA[2] = $t * $this->P20;
return $APA;
} | [
"public",
"function",
"authset",
"(",
"$",
"es",
")",
"{",
"#$t;",
"$",
"APA",
"=",
"array",
"(",
")",
";",
"$",
"APA",
"[",
"0",
"]",
"=",
"$",
"es",
"*",
"$",
"this",
"->",
"P00",
";",
"$",
"t",
"=",
"$",
"es",
"*",
"$",
"es",
";",
"$",... | determine latitude from authalic latitude
@param float $es
@return float | [
"determine",
"latitude",
"from",
"authalic",
"latitude"
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/projCode/Laea.php#L419-L432 |
41,095 | proj4php/proj4php | src/projCode/Eqdc.php | Eqdc.init | public function init()
{
// Place parameters in static storage for common use
if (! isset($this->mode)) {
//chosen default mode
$this->mode = 0;
}
$this->temp = $this->b / $this->a;
$this->es = 1.0 - pow( $this->temp, 2 );
$this->e = sqrt( $this->es );
$this->e0 = Common::e0fn( $this->es );
$this->e1 = Common::e1fn( $this->es );
$this->e2 = Common::e2fn( $this->es );
$this->e3 = Common::e3fn( $this->es );
$this->sinphi = sin( $this->lat1 );
$this->cosphi = cos( $this->lat1 );
$this->ms1 = Common::msfnz( $this->e, $this->sinphi, $this->cosphi );
$this->ml1 = Common::mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat1 );
// format B
if ($this->mode != 0) {
if (abs($this->lat1 + $this->lat2) < Common::EPSLN) {
Proj4php::reportError( "eqdc:Init:EqualLatitudes" );
//return(81);
}
$this->sinphi = sin($this->lat2);
$this->cosphi = cos($this->lat2);
$this->ms2 = Common::msfnz( $this->e, $this->sinphi, $this->cosphi );
$this->ml2 = Common::mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat2 );
if (abs($this->lat1 - $this->lat2) >= Common::EPSLN) {
$this->ns = ($this->ms1 - $this->ms2) / ($this->ml2 - $this->ml1);
} else {
$this->ns = $this->sinphi;
}
} else {
$this->ns = $this->sinphi;
}
$this->g = $this->ml1 + $this->ms1 / $this->ns;
$this->ml0 = Common::mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat0 );
$this->rh = $this->a * ($this->g - $this->ml0);
} | php | public function init()
{
// Place parameters in static storage for common use
if (! isset($this->mode)) {
//chosen default mode
$this->mode = 0;
}
$this->temp = $this->b / $this->a;
$this->es = 1.0 - pow( $this->temp, 2 );
$this->e = sqrt( $this->es );
$this->e0 = Common::e0fn( $this->es );
$this->e1 = Common::e1fn( $this->es );
$this->e2 = Common::e2fn( $this->es );
$this->e3 = Common::e3fn( $this->es );
$this->sinphi = sin( $this->lat1 );
$this->cosphi = cos( $this->lat1 );
$this->ms1 = Common::msfnz( $this->e, $this->sinphi, $this->cosphi );
$this->ml1 = Common::mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat1 );
// format B
if ($this->mode != 0) {
if (abs($this->lat1 + $this->lat2) < Common::EPSLN) {
Proj4php::reportError( "eqdc:Init:EqualLatitudes" );
//return(81);
}
$this->sinphi = sin($this->lat2);
$this->cosphi = cos($this->lat2);
$this->ms2 = Common::msfnz( $this->e, $this->sinphi, $this->cosphi );
$this->ml2 = Common::mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat2 );
if (abs($this->lat1 - $this->lat2) >= Common::EPSLN) {
$this->ns = ($this->ms1 - $this->ms2) / ($this->ml2 - $this->ml1);
} else {
$this->ns = $this->sinphi;
}
} else {
$this->ns = $this->sinphi;
}
$this->g = $this->ml1 + $this->ms1 / $this->ns;
$this->ml0 = Common::mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat0 );
$this->rh = $this->a * ($this->g - $this->ml0);
} | [
"public",
"function",
"init",
"(",
")",
"{",
"// Place parameters in static storage for common use\r",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"mode",
")",
")",
"{",
"//chosen default mode\r",
"$",
"this",
"->",
"mode",
"=",
"0",
";",
"}",
"$",
"thi... | Initialize the Equidistant Conic projection | [
"Initialize",
"the",
"Equidistant",
"Conic",
"projection"
] | 9550349f700a177ac7eb1f95639ab1c025e9c92c | https://github.com/proj4php/proj4php/blob/9550349f700a177ac7eb1f95639ab1c025e9c92c/src/projCode/Eqdc.php#L73-L124 |
41,096 | mbarwick83/shorty | src/Interfaces/ShortLinkAbstractInterface.php | ShortLinkAbstractInterface.request | protected function request($url,$context)
{
if (function_exists('curl_version')) {
$ch = curl_init();
if (array_key_exists("http", $context)) {
if (array_key_exists('method', $context["http"])) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $context["http"]["method"]);
}
if (array_key_exists("header", $context["http"])) {
$delimiter = strpos($context["http"]["header"], "\r\n") === false ? "\n" : "\r\n";
$headers = array_filter(explode($delimiter, $context["http"]["header"]), function($item) {
return !is_null($item);
});
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
if (array_key_exists("content", $context["http"])) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $context["http"]["content"]);
}
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
return file_get_contents($url,false,stream_context_create($context));
} | php | protected function request($url,$context)
{
if (function_exists('curl_version')) {
$ch = curl_init();
if (array_key_exists("http", $context)) {
if (array_key_exists('method', $context["http"])) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $context["http"]["method"]);
}
if (array_key_exists("header", $context["http"])) {
$delimiter = strpos($context["http"]["header"], "\r\n") === false ? "\n" : "\r\n";
$headers = array_filter(explode($delimiter, $context["http"]["header"]), function($item) {
return !is_null($item);
});
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
if (array_key_exists("content", $context["http"])) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $context["http"]["content"]);
}
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
return file_get_contents($url,false,stream_context_create($context));
} | [
"protected",
"function",
"request",
"(",
"$",
"url",
",",
"$",
"context",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'curl_version'",
")",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"\"http\"",
",",
"$"... | Performs the Request to the API server.
@param $url
@param $context
@return string | [
"Performs",
"the",
"Request",
"to",
"the",
"API",
"server",
"."
] | 3d4551b216bf7cc7aa6874de6f1b480404b025d3 | https://github.com/mbarwick83/shorty/blob/3d4551b216bf7cc7aa6874de6f1b480404b025d3/src/Interfaces/ShortLinkAbstractInterface.php#L34-L62 |
41,097 | mbarwick83/shorty | src/Shorty.php | Shorty.validate | protected function validate(&$data, $method)
{
if ( is_array($data) === false ) {
throw new InvalidApiResponseException('Google Url Shortener returned a response that could not be handled');
}
if (!empty($data['error']['errors'])) {
$error = json_encode($data['error']['errors']);
throw new InvalidApiResponseException('Google Url Shortener returned the following error: '.$error);
}
if (empty($data['status']) && $method == 'expand') {
throw new InvalidApiResponseException('Google Url Shortener has no status');
}
if ( !empty($data['status']) && $data['status']!='OK' && $method == 'expand') {
throw new InvalidApiResponseException('Google Url Shortener returned an invalid status');
}
if (empty($data['id'])) {
throw new InvalidApiResponseException('Google Url Shortener cannot provide the shortened Url');
}
if (empty($data['longUrl'])) {
throw new InvalidApiResponseException('Google Url Shortener cannot provide the original Url');
}
return $data;
} | php | protected function validate(&$data, $method)
{
if ( is_array($data) === false ) {
throw new InvalidApiResponseException('Google Url Shortener returned a response that could not be handled');
}
if (!empty($data['error']['errors'])) {
$error = json_encode($data['error']['errors']);
throw new InvalidApiResponseException('Google Url Shortener returned the following error: '.$error);
}
if (empty($data['status']) && $method == 'expand') {
throw new InvalidApiResponseException('Google Url Shortener has no status');
}
if ( !empty($data['status']) && $data['status']!='OK' && $method == 'expand') {
throw new InvalidApiResponseException('Google Url Shortener returned an invalid status');
}
if (empty($data['id'])) {
throw new InvalidApiResponseException('Google Url Shortener cannot provide the shortened Url');
}
if (empty($data['longUrl'])) {
throw new InvalidApiResponseException('Google Url Shortener cannot provide the original Url');
}
return $data;
} | [
"protected",
"function",
"validate",
"(",
"&",
"$",
"data",
",",
"$",
"method",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidApiResponseException",
"(",
"'Google Url Shortener returned a response that ... | Validates Google URL Shortener response and throws error messages, if any.
@param array $data
@param $method
@return array
@throws Exceptions\InvalidApiResponseException | [
"Validates",
"Google",
"URL",
"Shortener",
"response",
"and",
"throws",
"error",
"messages",
"if",
"any",
"."
] | 3d4551b216bf7cc7aa6874de6f1b480404b025d3 | https://github.com/mbarwick83/shorty/blob/3d4551b216bf7cc7aa6874de6f1b480404b025d3/src/Shorty.php#L122-L150 |
41,098 | mbarwick83/shorty | src/Shorty.php | Shorty.urlCheck | protected function urlCheck($url)
{
// first check if url has http:// prefix, if not, add it
$parsed = parse_url($url);
if (empty($parsed['scheme'])) {
$url = 'http://' . ltrim($url, '/');
}
$file_headers = get_headers($url);
if (!strpos($file_headers[0], "404 Not Found") > 0) {
return true;
}
return false;
} | php | protected function urlCheck($url)
{
// first check if url has http:// prefix, if not, add it
$parsed = parse_url($url);
if (empty($parsed['scheme'])) {
$url = 'http://' . ltrim($url, '/');
}
$file_headers = get_headers($url);
if (!strpos($file_headers[0], "404 Not Found") > 0) {
return true;
}
return false;
} | [
"protected",
"function",
"urlCheck",
"(",
"$",
"url",
")",
"{",
"// first check if url has http:// prefix, if not, add it",
"$",
"parsed",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"parsed",
"[",
"'scheme'",
"]",
")",
")",
"{... | Validates if the URL to submit actually exists and is accessible.
@param $url string URL being submitted.
@throws \Sonrisa\Service\ShortLink\Exceptions\InvalidApiResponseException
@return boolean | [
"Validates",
"if",
"the",
"URL",
"to",
"submit",
"actually",
"exists",
"and",
"is",
"accessible",
"."
] | 3d4551b216bf7cc7aa6874de6f1b480404b025d3 | https://github.com/mbarwick83/shorty/blob/3d4551b216bf7cc7aa6874de6f1b480404b025d3/src/Shorty.php#L158-L174 |
41,099 | protobuf-php/protobuf | src/Binary/Platform/BigEndian.php | BigEndian.isBigEndian | public static function isBigEndian()
{
if (self::$isBigEndian !== null) {
return self::$isBigEndian;
}
list(, $result) = unpack('L', pack('V', 1));
self::$isBigEndian = $result !== 1;
return self::$isBigEndian;
} | php | public static function isBigEndian()
{
if (self::$isBigEndian !== null) {
return self::$isBigEndian;
}
list(, $result) = unpack('L', pack('V', 1));
self::$isBigEndian = $result !== 1;
return self::$isBigEndian;
} | [
"public",
"static",
"function",
"isBigEndian",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"isBigEndian",
"!==",
"null",
")",
"{",
"return",
"self",
"::",
"$",
"isBigEndian",
";",
"}",
"list",
"(",
",",
"$",
"result",
")",
"=",
"unpack",
"(",
"'L'",... | Check if the current architecture is Big Endian.
@return bool | [
"Check",
"if",
"the",
"current",
"architecture",
"is",
"Big",
"Endian",
"."
] | c0da95f75ea418b39b02ff4528ca9926cc246a8c | https://github.com/protobuf-php/protobuf/blob/c0da95f75ea418b39b02ff4528ca9926cc246a8c/src/Binary/Platform/BigEndian.php#L28-L38 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.