repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
justinrainbow/json-schema | src/JsonSchema/Constraints/TypeConstraint.php | TypeConstraint.validateTypesArray | protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path, $coerce = false)
{
foreach ($type as $tp) {
// already valid, so no need to waste cycles looping over everything
if ($isValid) {
return;
}
// $t... | php | protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path, $coerce = false)
{
foreach ($type as $tp) {
// already valid, so no need to waste cycles looping over everything
if ($isValid) {
return;
}
// $t... | [
"protected",
"function",
"validateTypesArray",
"(",
"&",
"$",
"value",
",",
"array",
"$",
"type",
",",
"&",
"$",
"validTypesWording",
",",
"&",
"$",
"isValid",
",",
"$",
"path",
",",
"$",
"coerce",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"type",
... | Validates the given $value against the array of types in $type. Sets the value
of $isValid to true, if at least one $type mateches the type of $value or the value
passed as $isValid is already true.
@param mixed $value Value to validate
@param array $type TypeConstraints to check against
@para... | [
"Validates",
"the",
"given",
"$value",
"against",
"the",
"array",
"of",
"types",
"in",
"$type",
".",
"Sets",
"the",
"value",
"of",
"$isValid",
"to",
"true",
"if",
"at",
"least",
"one",
"$type",
"mateches",
"the",
"type",
"of",
"$value",
"or",
"the",
"val... | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/TypeConstraint.php#L90-L118 |
justinrainbow/json-schema | src/JsonSchema/Constraints/TypeConstraint.php | TypeConstraint.implodeWith | protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = false)
{
if ($listEnd === false || !isset($elements[1])) {
return implode($delimiter, $elements);
}
$lastElement = array_slice($elements, -1);
$firsElements = join($delimiter, array_slice($elem... | php | protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = false)
{
if ($listEnd === false || !isset($elements[1])) {
return implode($delimiter, $elements);
}
$lastElement = array_slice($elements, -1);
$firsElements = join($delimiter, array_slice($elem... | [
"protected",
"function",
"implodeWith",
"(",
"array",
"$",
"elements",
",",
"$",
"delimiter",
"=",
"', '",
",",
"$",
"listEnd",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"listEnd",
"===",
"false",
"||",
"!",
"isset",
"(",
"$",
"elements",
"[",
"1",
"]"... | Implodes the given array like implode() with turned around parameters and with the
difference, that, if $listEnd isn't false, the last element delimiter is $listEnd instead of
$delimiter.
@param array $elements The elements to implode
@param string $delimiter The delimiter to use
@param bool $listEnd The last de... | [
"Implodes",
"the",
"given",
"array",
"like",
"implode",
"()",
"with",
"turned",
"around",
"parameters",
"and",
"with",
"the",
"difference",
"that",
"if",
"$listEnd",
"isn",
"t",
"false",
"the",
"last",
"element",
"delimiter",
"is",
"$listEnd",
"instead",
"of",... | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/TypeConstraint.php#L131-L141 |
justinrainbow/json-schema | src/JsonSchema/Constraints/TypeConstraint.php | TypeConstraint.validateTypeNameWording | protected function validateTypeNameWording($type)
{
if (!isset(self::$wording[$type])) {
throw new StandardUnexpectedValueException(
sprintf(
'No wording for %s available, expected wordings are: [%s]',
var_export($type, true),
... | php | protected function validateTypeNameWording($type)
{
if (!isset(self::$wording[$type])) {
throw new StandardUnexpectedValueException(
sprintf(
'No wording for %s available, expected wordings are: [%s]',
var_export($type, true),
... | [
"protected",
"function",
"validateTypeNameWording",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"wording",
"[",
"$",
"type",
"]",
")",
")",
"{",
"throw",
"new",
"StandardUnexpectedValueException",
"(",
"sprintf",
"(",
"'No ... | Validates the given $type, if there's an associated self::$wording. If not, throws an
exception.
@param string $type The type to validate
@throws StandardUnexpectedValueException | [
"Validates",
"the",
"given",
"$type",
"if",
"there",
"s",
"an",
"associated",
"self",
"::",
"$wording",
".",
"If",
"not",
"throws",
"an",
"exception",
"."
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/TypeConstraint.php#L151-L161 |
justinrainbow/json-schema | src/JsonSchema/Constraints/TypeConstraint.php | TypeConstraint.validateType | protected function validateType(&$value, $type, $coerce = false)
{
//mostly the case for inline schema
if (!$type) {
return true;
}
if ('any' === $type) {
return true;
}
if ('object' === $type) {
return $this->getTypeCheck()->isOb... | php | protected function validateType(&$value, $type, $coerce = false)
{
//mostly the case for inline schema
if (!$type) {
return true;
}
if ('any' === $type) {
return true;
}
if ('object' === $type) {
return $this->getTypeCheck()->isOb... | [
"protected",
"function",
"validateType",
"(",
"&",
"$",
"value",
",",
"$",
"type",
",",
"$",
"coerce",
"=",
"false",
")",
"{",
"//mostly the case for inline schema",
"if",
"(",
"!",
"$",
"type",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"'any'",
... | Verifies that a given value is of a certain type
@param mixed $value Value to validate
@param string $type TypeConstraint to check against
@throws InvalidArgumentException
@return bool | [
"Verifies",
"that",
"a",
"given",
"value",
"is",
"of",
"a",
"certain",
"type"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/TypeConstraint.php#L173-L237 |
justinrainbow/json-schema | src/JsonSchema/Constraints/TypeConstraint.php | TypeConstraint.toBoolean | protected function toBoolean($value)
{
if ($value === 1 || $value === 'true') {
return true;
}
if (is_null($value) || $value === 0 || $value === 'false') {
return false;
}
if ($this->getTypeCheck()->isArray($value) && count($value) === 1) {
... | php | protected function toBoolean($value)
{
if ($value === 1 || $value === 'true') {
return true;
}
if (is_null($value) || $value === 0 || $value === 'false') {
return false;
}
if ($this->getTypeCheck()->isArray($value) && count($value) === 1) {
... | [
"protected",
"function",
"toBoolean",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"1",
"||",
"$",
"value",
"===",
"'true'",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
"||",
"$",
"value",
"... | Converts a value to boolean. For example, "true" becomes true.
@param $value The value to convert to boolean
@return bool|mixed | [
"Converts",
"a",
"value",
"to",
"boolean",
".",
"For",
"example",
"true",
"becomes",
"true",
"."
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/TypeConstraint.php#L246-L259 |
justinrainbow/json-schema | src/JsonSchema/Constraints/TypeConstraint.php | TypeConstraint.toNumber | protected function toNumber($value)
{
if (is_numeric($value)) {
return $value + 0; // cast to number
}
if (is_bool($value) || is_null($value)) {
return (int) $value;
}
if ($this->getTypeCheck()->isArray($value) && count($value) === 1) {
ret... | php | protected function toNumber($value)
{
if (is_numeric($value)) {
return $value + 0; // cast to number
}
if (is_bool($value) || is_null($value)) {
return (int) $value;
}
if ($this->getTypeCheck()->isArray($value) && count($value) === 1) {
ret... | [
"protected",
"function",
"toNumber",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
"+",
"0",
";",
"// cast to number",
"}",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
"||",
"is_null... | Converts a value to a number. For example, "4.5" becomes 4.5.
@param mixed $value the value to convert to a number
@return int|float|mixed | [
"Converts",
"a",
"value",
"to",
"a",
"number",
".",
"For",
"example",
"4",
".",
"5",
"becomes",
"4",
".",
"5",
"."
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/TypeConstraint.php#L268-L281 |
justinrainbow/json-schema | src/JsonSchema/Constraints/TypeConstraint.php | TypeConstraint.toInteger | protected function toInteger($value)
{
$numberValue = $this->toNumber($value);
if (is_numeric($numberValue) && (int) $numberValue == $numberValue) {
return (int) $numberValue; // cast to number
}
return $value;
} | php | protected function toInteger($value)
{
$numberValue = $this->toNumber($value);
if (is_numeric($numberValue) && (int) $numberValue == $numberValue) {
return (int) $numberValue; // cast to number
}
return $value;
} | [
"protected",
"function",
"toInteger",
"(",
"$",
"value",
")",
"{",
"$",
"numberValue",
"=",
"$",
"this",
"->",
"toNumber",
"(",
"$",
"value",
")",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"numberValue",
")",
"&&",
"(",
"int",
")",
"$",
"numberValue",
... | Converts a value to an integer. For example, "4" becomes 4.
@param mixed $value
@return int|mixed | [
"Converts",
"a",
"value",
"to",
"an",
"integer",
".",
"For",
"example",
"4",
"becomes",
"4",
"."
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/TypeConstraint.php#L290-L298 |
justinrainbow/json-schema | src/JsonSchema/Constraints/TypeConstraint.php | TypeConstraint.toString | protected function toString($value)
{
if (is_numeric($value)) {
return "$value";
}
if ($value === true) {
return 'true';
}
if ($value === false) {
return 'false';
}
if (is_null($value)) {
return '';
}
... | php | protected function toString($value)
{
if (is_numeric($value)) {
return "$value";
}
if ($value === true) {
return 'true';
}
if ($value === false) {
return 'false';
}
if (is_null($value)) {
return '';
}
... | [
"protected",
"function",
"toString",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"return",
"\"$value\"",
";",
"}",
"if",
"(",
"$",
"value",
"===",
"true",
")",
"{",
"return",
"'true'",
";",
"}",
"if",
"("... | Convert a value to a string representation of that value. For example, null becomes "".
@param mixed $value
@return string|mixed | [
"Convert",
"a",
"value",
"to",
"a",
"string",
"representation",
"of",
"that",
"value",
".",
"For",
"example",
"null",
"becomes",
"."
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/TypeConstraint.php#L323-L342 |
justinrainbow/json-schema | src/JsonSchema/Constraints/TypeConstraint.php | TypeConstraint.toNull | protected function toNull($value)
{
if ($value === 0 || $value === false || $value === '') {
return null;
}
if ($this->getTypeCheck()->isArray($value) && count($value) === 1) {
return $this->toNull(reset($value));
}
return $value;
} | php | protected function toNull($value)
{
if ($value === 0 || $value === false || $value === '') {
return null;
}
if ($this->getTypeCheck()->isArray($value) && count($value) === 1) {
return $this->toNull(reset($value));
}
return $value;
} | [
"protected",
"function",
"toNull",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"0",
"||",
"$",
"value",
"===",
"false",
"||",
"$",
"value",
"===",
"''",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getType... | Convert a value to a null. For example, 0 becomes null.
@param mixed $value
@return null|mixed | [
"Convert",
"a",
"value",
"to",
"a",
"null",
".",
"For",
"example",
"0",
"becomes",
"null",
"."
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/TypeConstraint.php#L351-L361 |
justinrainbow/json-schema | src/JsonSchema/Uri/UriResolver.php | UriResolver.parse | public function parse($uri)
{
preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
$components = array();
if (5 < count($match)) {
$components = array(
'scheme' => $match[2],
'authority' => $match[4],
... | php | public function parse($uri)
{
preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
$components = array();
if (5 < count($match)) {
$components = array(
'scheme' => $match[2],
'authority' => $match[4],
... | [
"public",
"function",
"parse",
"(",
"$",
"uri",
")",
"{",
"preg_match",
"(",
"'|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?|'",
",",
"$",
"uri",
",",
"$",
"match",
")",
";",
"$",
"components",
"=",
"array",
"(",
")",
";",
"if",
"(",
"5",
"<",
... | Parses a URI into five main components
@param string $uri
@return array | [
"Parses",
"a",
"URI",
"into",
"five",
"main",
"components"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Uri/UriResolver.php#L29-L49 |
justinrainbow/json-schema | src/JsonSchema/Uri/UriResolver.php | UriResolver.generate | public function generate(array $components)
{
$uri = $components['scheme'] . '://'
. $components['authority']
. $components['path'];
if (array_key_exists('query', $components) && strlen($components['query'])) {
$uri .= '?' . $components['query'];
}
... | php | public function generate(array $components)
{
$uri = $components['scheme'] . '://'
. $components['authority']
. $components['path'];
if (array_key_exists('query', $components) && strlen($components['query'])) {
$uri .= '?' . $components['query'];
}
... | [
"public",
"function",
"generate",
"(",
"array",
"$",
"components",
")",
"{",
"$",
"uri",
"=",
"$",
"components",
"[",
"'scheme'",
"]",
".",
"'://'",
".",
"$",
"components",
"[",
"'authority'",
"]",
".",
"$",
"components",
"[",
"'path'",
"]",
";",
"if",... | Builds a URI based on n array with the main components
@param array $components
@return string | [
"Builds",
"a",
"URI",
"based",
"on",
"n",
"array",
"with",
"the",
"main",
"components"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Uri/UriResolver.php#L58-L72 |
justinrainbow/json-schema | src/JsonSchema/Uri/UriResolver.php | UriResolver.resolve | public function resolve($uri, $baseUri = null)
{
// treat non-uri base as local file path
if (
!is_null($baseUri) &&
!filter_var($baseUri, \FILTER_VALIDATE_URL) &&
!preg_match('|^[^/]+://|u', $baseUri)
) {
if (is_file($baseUri)) {
... | php | public function resolve($uri, $baseUri = null)
{
// treat non-uri base as local file path
if (
!is_null($baseUri) &&
!filter_var($baseUri, \FILTER_VALIDATE_URL) &&
!preg_match('|^[^/]+://|u', $baseUri)
) {
if (is_file($baseUri)) {
... | [
"public",
"function",
"resolve",
"(",
"$",
"uri",
",",
"$",
"baseUri",
"=",
"null",
")",
"{",
"// treat non-uri base as local file path",
"if",
"(",
"!",
"is_null",
"(",
"$",
"baseUri",
")",
"&&",
"!",
"filter_var",
"(",
"$",
"baseUri",
",",
"\\",
"FILTER_... | {@inheritdoc} | [
"{"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Uri/UriResolver.php#L77-L113 |
justinrainbow/json-schema | src/JsonSchema/Uri/UriResolver.php | UriResolver.combineRelativePathWithBasePath | public static function combineRelativePathWithBasePath($relativePath, $basePath)
{
$relativePath = self::normalizePath($relativePath);
if ($relativePath == '') {
return $basePath;
}
if ($relativePath[0] == '/') {
return $relativePath;
}
$baseP... | php | public static function combineRelativePathWithBasePath($relativePath, $basePath)
{
$relativePath = self::normalizePath($relativePath);
if ($relativePath == '') {
return $basePath;
}
if ($relativePath[0] == '/') {
return $relativePath;
}
$baseP... | [
"public",
"static",
"function",
"combineRelativePathWithBasePath",
"(",
"$",
"relativePath",
",",
"$",
"basePath",
")",
"{",
"$",
"relativePath",
"=",
"self",
"::",
"normalizePath",
"(",
"$",
"relativePath",
")",
";",
"if",
"(",
"$",
"relativePath",
"==",
"''"... | Tries to glue a relative path onto an absolute one
@param string $relativePath
@param string $basePath
@throws UriResolverException
@return string Merged path | [
"Tries",
"to",
"glue",
"a",
"relative",
"path",
"onto",
"an",
"absolute",
"one"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Uri/UriResolver.php#L125-L147 |
justinrainbow/json-schema | src/JsonSchema/Uri/UriRetriever.php | UriRetriever.confirmMediaType | public function confirmMediaType($uriRetriever, $uri)
{
$contentType = $uriRetriever->getContentType();
if (is_null($contentType)) {
// Well, we didn't get an invalid one
return;
}
if (in_array($contentType, array(Validator::SCHEMA_MEDIA_TYPE, 'application/j... | php | public function confirmMediaType($uriRetriever, $uri)
{
$contentType = $uriRetriever->getContentType();
if (is_null($contentType)) {
// Well, we didn't get an invalid one
return;
}
if (in_array($contentType, array(Validator::SCHEMA_MEDIA_TYPE, 'application/j... | [
"public",
"function",
"confirmMediaType",
"(",
"$",
"uriRetriever",
",",
"$",
"uri",
")",
"{",
"$",
"contentType",
"=",
"$",
"uriRetriever",
"->",
"getContentType",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"contentType",
")",
")",
"{",
"// Well, we d... | Guarantee the correct media type was encountered
@param UriRetrieverInterface $uriRetriever
@param string $uri
@return bool|void | [
"Guarantee",
"the",
"correct",
"media",
"type",
"was",
"encountered"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Uri/UriRetriever.php#L73-L93 |
justinrainbow/json-schema | src/JsonSchema/Uri/UriRetriever.php | UriRetriever.resolvePointer | public function resolvePointer($jsonSchema, $uri)
{
$resolver = new UriResolver();
$parsed = $resolver->parse($uri);
if (empty($parsed['fragment'])) {
return $jsonSchema;
}
$path = explode('/', $parsed['fragment']);
while ($path) {
$pathElemen... | php | public function resolvePointer($jsonSchema, $uri)
{
$resolver = new UriResolver();
$parsed = $resolver->parse($uri);
if (empty($parsed['fragment'])) {
return $jsonSchema;
}
$path = explode('/', $parsed['fragment']);
while ($path) {
$pathElemen... | [
"public",
"function",
"resolvePointer",
"(",
"$",
"jsonSchema",
",",
"$",
"uri",
")",
"{",
"$",
"resolver",
"=",
"new",
"UriResolver",
"(",
")",
";",
"$",
"parsed",
"=",
"$",
"resolver",
"->",
"parse",
"(",
"$",
"uri",
")",
";",
"if",
"(",
"empty",
... | Resolve a schema based on pointer
URIs can have a fragment at the end in the format of
#/path/to/object and we are to look up the 'path' property of
the first object then the 'to' and 'object' properties.
@param object $jsonSchema JSON Schema contents
@param string $uri JSON Schema URI
@throws ResourceNotFoun... | [
"Resolve",
"a",
"schema",
"based",
"on",
"pointer"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Uri/UriRetriever.php#L126-L159 |
justinrainbow/json-schema | src/JsonSchema/Uri/UriRetriever.php | UriRetriever.retrieve | public function retrieve($uri, $baseUri = null, $translate = true)
{
$resolver = new UriResolver();
$resolvedUri = $fetchUri = $resolver->resolve($uri, $baseUri);
//fetch URL without #fragment
$arParts = $resolver->parse($resolvedUri);
if (isset($arParts['fragment'])) {
... | php | public function retrieve($uri, $baseUri = null, $translate = true)
{
$resolver = new UriResolver();
$resolvedUri = $fetchUri = $resolver->resolve($uri, $baseUri);
//fetch URL without #fragment
$arParts = $resolver->parse($resolvedUri);
if (isset($arParts['fragment'])) {
... | [
"public",
"function",
"retrieve",
"(",
"$",
"uri",
",",
"$",
"baseUri",
"=",
"null",
",",
"$",
"translate",
"=",
"true",
")",
"{",
"$",
"resolver",
"=",
"new",
"UriResolver",
"(",
")",
";",
"$",
"resolvedUri",
"=",
"$",
"fetchUri",
"=",
"$",
"resolve... | {@inheritdoc} | [
"{"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Uri/UriRetriever.php#L164-L191 |
justinrainbow/json-schema | src/JsonSchema/Uri/UriRetriever.php | UriRetriever.loadSchema | protected function loadSchema($fetchUri)
{
if (isset($this->schemaCache[$fetchUri])) {
return $this->schemaCache[$fetchUri];
}
$uriRetriever = $this->getUriRetriever();
$contents = $this->uriRetriever->retrieve($fetchUri);
$this->confirmMediaType($uriRetriever, $... | php | protected function loadSchema($fetchUri)
{
if (isset($this->schemaCache[$fetchUri])) {
return $this->schemaCache[$fetchUri];
}
$uriRetriever = $this->getUriRetriever();
$contents = $this->uriRetriever->retrieve($fetchUri);
$this->confirmMediaType($uriRetriever, $... | [
"protected",
"function",
"loadSchema",
"(",
"$",
"fetchUri",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"schemaCache",
"[",
"$",
"fetchUri",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"schemaCache",
"[",
"$",
"fetchUri",
"]",
";",
"}... | Fetch a schema from the given URI, json-decode it and return it.
Caches schema objects.
@param string $fetchUri Absolute URI
@return object JSON schema object | [
"Fetch",
"a",
"schema",
"from",
"the",
"given",
"URI",
"json",
"-",
"decode",
"it",
"and",
"return",
"it",
".",
"Caches",
"schema",
"objects",
"."
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Uri/UriRetriever.php#L201-L219 |
justinrainbow/json-schema | src/JsonSchema/Uri/UriRetriever.php | UriRetriever.resolve | public function resolve($uri, $baseUri = null)
{
$components = $this->parse($uri);
$path = $components['path'];
if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
return $uri;
}
$baseComponents = $this->parse($baseUri);
... | php | public function resolve($uri, $baseUri = null)
{
$components = $this->parse($uri);
$path = $components['path'];
if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
return $uri;
}
$baseComponents = $this->parse($baseUri);
... | [
"public",
"function",
"resolve",
"(",
"$",
"uri",
",",
"$",
"baseUri",
"=",
"null",
")",
"{",
"$",
"components",
"=",
"$",
"this",
"->",
"parse",
"(",
"$",
"uri",
")",
";",
"$",
"path",
"=",
"$",
"components",
"[",
"'path'",
"]",
";",
"if",
"(",
... | Resolves a URI
@param string $uri Absolute or relative
@param string $baseUri Optional base URI
@return string | [
"Resolves",
"a",
"URI"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Uri/UriRetriever.php#L298-L313 |
justinrainbow/json-schema | src/JsonSchema/Uri/UriRetriever.php | UriRetriever.translate | public function translate($uri)
{
foreach ($this->translationMap as $from => $to) {
$uri = preg_replace($from, $to, $uri);
}
// translate references to local files within the json-schema package
$uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ ... | php | public function translate($uri)
{
foreach ($this->translationMap as $from => $to) {
$uri = preg_replace($from, $to, $uri);
}
// translate references to local files within the json-schema package
$uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ ... | [
"public",
"function",
"translate",
"(",
"$",
"uri",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"translationMap",
"as",
"$",
"from",
"=>",
"$",
"to",
")",
"{",
"$",
"uri",
"=",
"preg_replace",
"(",
"$",
"from",
",",
"$",
"to",
",",
"$",
"uri",
"... | Apply URI translation rules | [
"Apply",
"URI",
"translation",
"rules"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Uri/UriRetriever.php#L338-L348 |
justinrainbow/json-schema | src/JsonSchema/Constraints/ObjectConstraint.php | ObjectConstraint.check | public function check(&$element, $schema = null, JsonPointer $path = null, $properties = null,
$additionalProp = null, $patternProperties = null, $appliedDefaults = array())
{
if ($element instanceof UndefinedConstraint) {
return;
}
$this->appliedDefaults = $appliedDefau... | php | public function check(&$element, $schema = null, JsonPointer $path = null, $properties = null,
$additionalProp = null, $patternProperties = null, $appliedDefaults = array())
{
if ($element instanceof UndefinedConstraint) {
return;
}
$this->appliedDefaults = $appliedDefau... | [
"public",
"function",
"check",
"(",
"&",
"$",
"element",
",",
"$",
"schema",
"=",
"null",
",",
"JsonPointer",
"$",
"path",
"=",
"null",
",",
"$",
"properties",
"=",
"null",
",",
"$",
"additionalProp",
"=",
"null",
",",
"$",
"patternProperties",
"=",
"n... | {@inheritdoc} | [
"{"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/ObjectConstraint.php#L31-L53 |
justinrainbow/json-schema | src/JsonSchema/Constraints/ObjectConstraint.php | ObjectConstraint.validateElement | public function validateElement($element, $matches, $schema = null, JsonPointer $path = null,
$properties = null, $additionalProp = null)
{
$this->validateMinMaxConstraint($element, $schema, $path);
foreach ($element as $i => $value) {
$definition = $this->getProperty($propertie... | php | public function validateElement($element, $matches, $schema = null, JsonPointer $path = null,
$properties = null, $additionalProp = null)
{
$this->validateMinMaxConstraint($element, $schema, $path);
foreach ($element as $i => $value) {
$definition = $this->getProperty($propertie... | [
"public",
"function",
"validateElement",
"(",
"$",
"element",
",",
"$",
"matches",
",",
"$",
"schema",
"=",
"null",
",",
"JsonPointer",
"$",
"path",
"=",
"null",
",",
"$",
"properties",
"=",
"null",
",",
"$",
"additionalProp",
"=",
"null",
")",
"{",
"$... | Validates the element properties
@param \StdClass $element Element to validate
@param array $matches Matches from patternProperties (if any)
@param \StdClass $schema ObjectConstraint definition
@param JsonPointer|null $path Current test path
@param \StdClass ... | [
"Validates",
"the",
"element",
"properties"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/ObjectConstraint.php#L94-L130 |
justinrainbow/json-schema | src/JsonSchema/Constraints/ObjectConstraint.php | ObjectConstraint.validateProperties | public function validateProperties(&$element, $properties = null, JsonPointer $path = null)
{
$undefinedConstraint = $this->factory->createInstanceFor('undefined');
foreach ($properties as $i => $value) {
$property = &$this->getProperty($element, $i, $undefinedConstraint);
$... | php | public function validateProperties(&$element, $properties = null, JsonPointer $path = null)
{
$undefinedConstraint = $this->factory->createInstanceFor('undefined');
foreach ($properties as $i => $value) {
$property = &$this->getProperty($element, $i, $undefinedConstraint);
$... | [
"public",
"function",
"validateProperties",
"(",
"&",
"$",
"element",
",",
"$",
"properties",
"=",
"null",
",",
"JsonPointer",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"undefinedConstraint",
"=",
"$",
"this",
"->",
"factory",
"->",
"createInstanceFor",
"(",
... | Validates the definition properties
@param \stdClass $element Element to validate
@param \stdClass $properties Property definitions
@param JsonPointer|null $path Path? | [
"Validates",
"the",
"definition",
"properties"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/ObjectConstraint.php#L139-L152 |
justinrainbow/json-schema | src/JsonSchema/Constraints/ObjectConstraint.php | ObjectConstraint.& | protected function &getProperty(&$element, $property, $fallback = null)
{
if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element)) /*$this->checkMode == self::CHECK_MODE_TYPE_CAST*/) {
return $element[$property];
} elseif (is_object($element) && pro... | php | protected function &getProperty(&$element, $property, $fallback = null)
{
if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element)) /*$this->checkMode == self::CHECK_MODE_TYPE_CAST*/) {
return $element[$property];
} elseif (is_object($element) && pro... | [
"protected",
"function",
"&",
"getProperty",
"(",
"&",
"$",
"element",
",",
"$",
"property",
",",
"$",
"fallback",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"element",
")",
"&&",
"(",
"isset",
"(",
"$",
"element",
"[",
"$",
"property",
... | retrieves a property from an object or array
@param mixed $element Element to validate
@param string $property Property to retrieve
@param mixed $fallback Default value if property is not found
@return mixed | [
"retrieves",
"a",
"property",
"from",
"an",
"object",
"or",
"array"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/ObjectConstraint.php#L163-L172 |
justinrainbow/json-schema | src/JsonSchema/Constraints/ObjectConstraint.php | ObjectConstraint.validateMinMaxConstraint | protected function validateMinMaxConstraint($element, $objectDefinition, JsonPointer $path = null)
{
// Verify minimum number of properties
if (isset($objectDefinition->minProperties) && !is_object($objectDefinition->minProperties)) {
if ($this->getTypeCheck()->propertyCount($element) < ... | php | protected function validateMinMaxConstraint($element, $objectDefinition, JsonPointer $path = null)
{
// Verify minimum number of properties
if (isset($objectDefinition->minProperties) && !is_object($objectDefinition->minProperties)) {
if ($this->getTypeCheck()->propertyCount($element) < ... | [
"protected",
"function",
"validateMinMaxConstraint",
"(",
"$",
"element",
",",
"$",
"objectDefinition",
",",
"JsonPointer",
"$",
"path",
"=",
"null",
")",
"{",
"// Verify minimum number of properties",
"if",
"(",
"isset",
"(",
"$",
"objectDefinition",
"->",
"minProp... | validating minimum and maximum property constraints (if present) against an element
@param \stdClass $element Element to validate
@param \stdClass $objectDefinition ObjectConstraint definition
@param JsonPointer|null $path Path to test? | [
"validating",
"minimum",
"and",
"maximum",
"property",
"constraints",
"(",
"if",
"present",
")",
"against",
"an",
"element"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/ObjectConstraint.php#L181-L195 |
justinrainbow/json-schema | src/JsonSchema/Validator.php | Validator.validate | public function validate(&$value, $schema = null, $checkMode = null)
{
// reset errors prior to validation
$this->reset();
// set checkMode
$initialCheckMode = $this->factory->getConfig();
if ($checkMode !== null) {
$this->factory->setConfig($checkMode);
... | php | public function validate(&$value, $schema = null, $checkMode = null)
{
// reset errors prior to validation
$this->reset();
// set checkMode
$initialCheckMode = $this->factory->getConfig();
if ($checkMode !== null) {
$this->factory->setConfig($checkMode);
... | [
"public",
"function",
"validate",
"(",
"&",
"$",
"value",
",",
"$",
"schema",
"=",
"null",
",",
"$",
"checkMode",
"=",
"null",
")",
"{",
"// reset errors prior to validation",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"// set checkMode",
"$",
"initialCheckM... | Validates the given data against the schema and returns an object containing the results
Both the php object and the schema are supposed to be a result of a json_decode call.
The validation works as defined by the schema proposal in http://json-schema.org.
Note that the first argument is passed by reference, so you mu... | [
"Validates",
"the",
"given",
"data",
"against",
"the",
"schema",
"and",
"returns",
"an",
"object",
"containing",
"the",
"results",
"Both",
"the",
"php",
"object",
"and",
"the",
"schema",
"are",
"supposed",
"to",
"be",
"a",
"result",
"of",
"a",
"json_decode",... | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Validator.php#L41-L71 |
justinrainbow/json-schema | src/JsonSchema/Rfc3339.php | Rfc3339.createFromString | public static function createFromString($string)
{
if (!preg_match(self::REGEX, strtoupper($string), $matches)) {
return null;
}
$dateAndTime = $matches[1];
$microseconds = $matches[2] ?: '.000000';
$timeZone = 'Z' !== $matches[3] ? $matches[4] . ':' . $matches[5... | php | public static function createFromString($string)
{
if (!preg_match(self::REGEX, strtoupper($string), $matches)) {
return null;
}
$dateAndTime = $matches[1];
$microseconds = $matches[2] ?: '.000000';
$timeZone = 'Z' !== $matches[3] ? $matches[4] . ':' . $matches[5... | [
"public",
"static",
"function",
"createFromString",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"self",
"::",
"REGEX",
",",
"strtoupper",
"(",
"$",
"string",
")",
",",
"$",
"matches",
")",
")",
"{",
"return",
"null",
";",
"}",
"$... | Try creating a DateTime instance
@param string $string
@return \DateTime|null | [
"Try",
"creating",
"a",
"DateTime",
"instance"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Rfc3339.php#L16-L29 |
justinrainbow/json-schema | src/JsonSchema/Constraints/UndefinedConstraint.php | UndefinedConstraint.check | public function check(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
{
if (is_null($schema) || !is_object($schema)) {
return;
}
$path = $this->incrementPath($path ?: new JsonPointer(''), $i);
if ($fromDefault) {
$path->set... | php | public function check(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
{
if (is_null($schema) || !is_object($schema)) {
return;
}
$path = $this->incrementPath($path ?: new JsonPointer(''), $i);
if ($fromDefault) {
$path->set... | [
"public",
"function",
"check",
"(",
"&",
"$",
"value",
",",
"$",
"schema",
"=",
"null",
",",
"JsonPointer",
"$",
"path",
"=",
"null",
",",
"$",
"i",
"=",
"null",
",",
"$",
"fromDefault",
"=",
"false",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"sc... | {@inheritdoc} | [
"{"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/UndefinedConstraint.php#L34-L53 |
justinrainbow/json-schema | src/JsonSchema/Constraints/UndefinedConstraint.php | UndefinedConstraint.validateTypes | public function validateTypes(&$value, $schema = null, JsonPointer $path, $i = null)
{
// check array
if ($this->getTypeCheck()->isArray($value)) {
$this->checkArray($value, $schema, $path, $i);
}
// check object
if (LooseTypeCheck::isObject($value)) { // object ... | php | public function validateTypes(&$value, $schema = null, JsonPointer $path, $i = null)
{
// check array
if ($this->getTypeCheck()->isArray($value)) {
$this->checkArray($value, $schema, $path, $i);
}
// check object
if (LooseTypeCheck::isObject($value)) { // object ... | [
"public",
"function",
"validateTypes",
"(",
"&",
"$",
"value",
",",
"$",
"schema",
"=",
"null",
",",
"JsonPointer",
"$",
"path",
",",
"$",
"i",
"=",
"null",
")",
"{",
"// check array",
"if",
"(",
"$",
"this",
"->",
"getTypeCheck",
"(",
")",
"->",
"is... | Validates the value against the types
@param mixed $value
@param mixed $schema
@param JsonPointer $path
@param string $i | [
"Validates",
"the",
"value",
"against",
"the",
"types"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/UndefinedConstraint.php#L63-L104 |
justinrainbow/json-schema | src/JsonSchema/Constraints/UndefinedConstraint.php | UndefinedConstraint.validateCommonProperties | protected function validateCommonProperties(&$value, $schema = null, JsonPointer $path, $i = '')
{
// if it extends another schema, it must pass that schema as well
if (isset($schema->extends)) {
if (is_string($schema->extends)) {
$schema->extends = $this->validateUri($sc... | php | protected function validateCommonProperties(&$value, $schema = null, JsonPointer $path, $i = '')
{
// if it extends another schema, it must pass that schema as well
if (isset($schema->extends)) {
if (is_string($schema->extends)) {
$schema->extends = $this->validateUri($sc... | [
"protected",
"function",
"validateCommonProperties",
"(",
"&",
"$",
"value",
",",
"$",
"schema",
"=",
"null",
",",
"JsonPointer",
"$",
"path",
",",
"$",
"i",
"=",
"''",
")",
"{",
"// if it extends another schema, it must pass that schema as well",
"if",
"(",
"isse... | Validates common properties
@param mixed $value
@param mixed $schema
@param JsonPointer $path
@param string $i | [
"Validates",
"common",
"properties"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/UndefinedConstraint.php#L114-L202 |
justinrainbow/json-schema | src/JsonSchema/Constraints/UndefinedConstraint.php | UndefinedConstraint.shouldApplyDefaultValue | private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $parentSchema = null)
{
// required-only mode is off
if (!$requiredOnly) {
return true;
}
// draft-04 required is set
if (
$name !== null
&& isset($parentSchema-... | php | private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $parentSchema = null)
{
// required-only mode is off
if (!$requiredOnly) {
return true;
}
// draft-04 required is set
if (
$name !== null
&& isset($parentSchema-... | [
"private",
"function",
"shouldApplyDefaultValue",
"(",
"$",
"requiredOnly",
",",
"$",
"schema",
",",
"$",
"name",
"=",
"null",
",",
"$",
"parentSchema",
"=",
"null",
")",
"{",
"// required-only mode is off",
"if",
"(",
"!",
"$",
"requiredOnly",
")",
"{",
"re... | Check whether a default should be applied for this value
@param mixed $schema
@param mixed $parentSchema
@param bool $requiredOnly
@return bool | [
"Check",
"whether",
"a",
"default",
"should",
"be",
"applied",
"for",
"this",
"value"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/UndefinedConstraint.php#L213-L234 |
justinrainbow/json-schema | src/JsonSchema/Constraints/UndefinedConstraint.php | UndefinedConstraint.applyDefaultValues | protected function applyDefaultValues(&$value, $schema, $path)
{
// only apply defaults if feature is enabled
if (!$this->factory->getConfig(self::CHECK_MODE_APPLY_DEFAULTS)) {
return;
}
// apply defaults if appropriate
$requiredOnly = $this->factory->getConfig(s... | php | protected function applyDefaultValues(&$value, $schema, $path)
{
// only apply defaults if feature is enabled
if (!$this->factory->getConfig(self::CHECK_MODE_APPLY_DEFAULTS)) {
return;
}
// apply defaults if appropriate
$requiredOnly = $this->factory->getConfig(s... | [
"protected",
"function",
"applyDefaultValues",
"(",
"&",
"$",
"value",
",",
"$",
"schema",
",",
"$",
"path",
")",
"{",
"// only apply defaults if feature is enabled",
"if",
"(",
"!",
"$",
"this",
"->",
"factory",
"->",
"getConfig",
"(",
"self",
"::",
"CHECK_MO... | Apply default values
@param mixed $value
@param mixed $schema
@param JsonPointer $path | [
"Apply",
"default",
"values"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/UndefinedConstraint.php#L243-L300 |
justinrainbow/json-schema | src/JsonSchema/Constraints/UndefinedConstraint.php | UndefinedConstraint.validateOfProperties | protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
{
// Verify type
if ($value instanceof self) {
return;
}
if (isset($schema->allOf)) {
$isValid = true;
foreach ($schema->allOf as $allOf) {
$init... | php | protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
{
// Verify type
if ($value instanceof self) {
return;
}
if (isset($schema->allOf)) {
$isValid = true;
foreach ($schema->allOf as $allOf) {
$init... | [
"protected",
"function",
"validateOfProperties",
"(",
"&",
"$",
"value",
",",
"$",
"schema",
",",
"JsonPointer",
"$",
"path",
",",
"$",
"i",
"=",
"''",
")",
"{",
"// Verify type",
"if",
"(",
"$",
"value",
"instanceof",
"self",
")",
"{",
"return",
";",
... | Validate allOf, anyOf, and oneOf properties
@param mixed $value
@param mixed $schema
@param JsonPointer $path
@param string $i | [
"Validate",
"allOf",
"anyOf",
"and",
"oneOf",
"properties"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/UndefinedConstraint.php#L310-L375 |
justinrainbow/json-schema | src/JsonSchema/Constraints/UndefinedConstraint.php | UndefinedConstraint.validateDependencies | protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '')
{
foreach ($dependencies as $key => $dependency) {
if ($this->getTypeCheck()->propertyExists($value, $key)) {
if (is_string($dependency)) {
// Draft 3 string is allowed ... | php | protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '')
{
foreach ($dependencies as $key => $dependency) {
if ($this->getTypeCheck()->propertyExists($value, $key)) {
if (is_string($dependency)) {
// Draft 3 string is allowed ... | [
"protected",
"function",
"validateDependencies",
"(",
"$",
"value",
",",
"$",
"dependencies",
",",
"JsonPointer",
"$",
"path",
",",
"$",
"i",
"=",
"''",
")",
"{",
"foreach",
"(",
"$",
"dependencies",
"as",
"$",
"key",
"=>",
"$",
"dependency",
")",
"{",
... | Validate dependencies
@param mixed $value
@param mixed $dependencies
@param JsonPointer $path
@param string $i | [
"Validate",
"dependencies"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/UndefinedConstraint.php#L385-L413 |
justinrainbow/json-schema | src/JsonSchema/Entity/JsonPointer.php | JsonPointer.decodePropertyPaths | private function decodePropertyPaths($propertyPathString)
{
$paths = array();
foreach (explode('/', trim($propertyPathString, '/')) as $path) {
$path = $this->decodePath($path);
if (is_string($path) && '' !== $path) {
$paths[] = $path;
}
}
... | php | private function decodePropertyPaths($propertyPathString)
{
$paths = array();
foreach (explode('/', trim($propertyPathString, '/')) as $path) {
$path = $this->decodePath($path);
if (is_string($path) && '' !== $path) {
$paths[] = $path;
}
}
... | [
"private",
"function",
"decodePropertyPaths",
"(",
"$",
"propertyPathString",
")",
"{",
"$",
"paths",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"explode",
"(",
"'/'",
",",
"trim",
"(",
"$",
"propertyPathString",
",",
"'/'",
")",
")",
"as",
"$",
"path"... | @param string $propertyPathString
@return string[] | [
"@param",
"string",
"$propertyPathString"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Entity/JsonPointer.php#L55-L66 |
justinrainbow/json-schema | src/JsonSchema/Constraints/FormatConstraint.php | FormatConstraint.check | public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
{
if (!isset($schema->format) || $this->factory->getConfig(self::CHECK_MODE_DISABLE_FORMAT)) {
return;
}
switch ($schema->format) {
case 'date':
if (!$date = $this->... | php | public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
{
if (!isset($schema->format) || $this->factory->getConfig(self::CHECK_MODE_DISABLE_FORMAT)) {
return;
}
switch ($schema->format) {
case 'date':
if (!$date = $this->... | [
"public",
"function",
"check",
"(",
"&",
"$",
"element",
",",
"$",
"schema",
"=",
"null",
",",
"JsonPointer",
"$",
"path",
"=",
"null",
",",
"$",
"i",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"schema",
"->",
"format",
")",
"||",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/FormatConstraint.php#L28-L173 |
justinrainbow/json-schema | src/JsonSchema/Constraints/BaseConstraint.php | BaseConstraint.arrayToObjectRecursive | public static function arrayToObjectRecursive($array)
{
$json = json_encode($array);
if (json_last_error() !== \JSON_ERROR_NONE) {
$message = 'Unable to encode schema array as JSON';
if (function_exists('json_last_error_msg')) {
$message .= ': ' . json_last_er... | php | public static function arrayToObjectRecursive($array)
{
$json = json_encode($array);
if (json_last_error() !== \JSON_ERROR_NONE) {
$message = 'Unable to encode schema array as JSON';
if (function_exists('json_last_error_msg')) {
$message .= ': ' . json_last_er... | [
"public",
"static",
"function",
"arrayToObjectRecursive",
"(",
"$",
"array",
")",
"{",
"$",
"json",
"=",
"json_encode",
"(",
"$",
"array",
")",
";",
"if",
"(",
"json_last_error",
"(",
")",
"!==",
"\\",
"JSON_ERROR_NONE",
")",
"{",
"$",
"message",
"=",
"'... | Recursively cast an associative array to an object
@param array $array
@return object | [
"Recursively",
"cast",
"an",
"associative",
"array",
"to",
"an",
"object"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/BaseConstraint.php#L143-L155 |
justinrainbow/json-schema | src/JsonSchema/Constraints/NumberConstraint.php | NumberConstraint.check | public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
{
// Verify minimum
if (isset($schema->exclusiveMinimum)) {
if (isset($schema->minimum)) {
if ($schema->exclusiveMinimum && $element <= $schema->minimum) {
$this->add... | php | public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
{
// Verify minimum
if (isset($schema->exclusiveMinimum)) {
if (isset($schema->minimum)) {
if ($schema->exclusiveMinimum && $element <= $schema->minimum) {
$this->add... | [
"public",
"function",
"check",
"(",
"&",
"$",
"element",
",",
"$",
"schema",
"=",
"null",
",",
"JsonPointer",
"$",
"path",
"=",
"null",
",",
"$",
"i",
"=",
"null",
")",
"{",
"// Verify minimum",
"if",
"(",
"isset",
"(",
"$",
"schema",
"->",
"exclusiv... | {@inheritdoc} | [
"{"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/NumberConstraint.php#L26-L69 |
justinrainbow/json-schema | src/JsonSchema/Iterator/ObjectIterator.php | ObjectIterator.initialize | private function initialize()
{
if (!$this->initialized) {
$this->data = $this->buildDataFromObject($this->object);
$this->initialized = true;
}
} | php | private function initialize()
{
if (!$this->initialized) {
$this->data = $this->buildDataFromObject($this->object);
$this->initialized = true;
}
} | [
"private",
"function",
"initialize",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"initialized",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"this",
"->",
"buildDataFromObject",
"(",
"$",
"this",
"->",
"object",
")",
";",
"$",
"this",
"->",
... | Initializer | [
"Initializer"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Iterator/ObjectIterator.php#L100-L106 |
justinrainbow/json-schema | src/JsonSchema/Iterator/ObjectIterator.php | ObjectIterator.buildDataFromObject | private function buildDataFromObject($object)
{
$result = array();
$stack = new \SplStack();
$stack->push($object);
while (!$stack->isEmpty()) {
$current = $stack->pop();
if (is_object($current)) {
array_push($result, $current);
}... | php | private function buildDataFromObject($object)
{
$result = array();
$stack = new \SplStack();
$stack->push($object);
while (!$stack->isEmpty()) {
$current = $stack->pop();
if (is_object($current)) {
array_push($result, $current);
}... | [
"private",
"function",
"buildDataFromObject",
"(",
"$",
"object",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"stack",
"=",
"new",
"\\",
"SplStack",
"(",
")",
";",
"$",
"stack",
"->",
"push",
"(",
"$",
"object",
")",
";",
"while",
"(... | @param object $object
@return array | [
"@param",
"object",
"$object"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Iterator/ObjectIterator.php#L113-L134 |
justinrainbow/json-schema | src/JsonSchema/Iterator/ObjectIterator.php | ObjectIterator.getDataFromItem | private function getDataFromItem($item)
{
if (!is_object($item) && !is_array($item)) {
return array();
}
return is_object($item) ? get_object_vars($item) : $item;
} | php | private function getDataFromItem($item)
{
if (!is_object($item) && !is_array($item)) {
return array();
}
return is_object($item) ? get_object_vars($item) : $item;
} | [
"private",
"function",
"getDataFromItem",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"item",
")",
"&&",
"!",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"return",
"is_object",
"(",
"$"... | @param object|array $item
@return array | [
"@param",
"object|array",
"$item"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Iterator/ObjectIterator.php#L141-L148 |
justinrainbow/json-schema | src/JsonSchema/Constraints/StringConstraint.php | StringConstraint.check | public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
{
// Verify maxLength
if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) {
$this->addError(ConstraintError::LENGTH_MAX(), $path, array(
'maxLength' => $schema... | php | public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
{
// Verify maxLength
if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) {
$this->addError(ConstraintError::LENGTH_MAX(), $path, array(
'maxLength' => $schema... | [
"public",
"function",
"check",
"(",
"&",
"$",
"element",
",",
"$",
"schema",
"=",
"null",
",",
"JsonPointer",
"$",
"path",
"=",
"null",
",",
"$",
"i",
"=",
"null",
")",
"{",
"// Verify maxLength",
"if",
"(",
"isset",
"(",
"$",
"schema",
"->",
"maxLen... | {@inheritdoc} | [
"{"
] | train | https://github.com/justinrainbow/json-schema/blob/775a4f5dc786a43d42f649dad6d84b1ba431895b/src/JsonSchema/Constraints/StringConstraint.php#L26-L50 |
TelegramBot/Api | src/Types/User.php | User.setId | public function setId($id)
{
if (is_integer($id) || is_float($id)) {
$this->id = $id;
} else {
throw new InvalidArgumentException();
}
} | php | public function setId($id)
{
if (is_integer($id) || is_float($id)) {
$this->id = $id;
} else {
throw new InvalidArgumentException();
}
} | [
"public",
"function",
"setId",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"is_integer",
"(",
"$",
"id",
")",
"||",
"is_float",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"$",
"id",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgu... | @param int $id
@throws InvalidArgumentException | [
"@param",
"int",
"$id"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/Types/User.php#L109-L116 |
TelegramBot/Api | src/Events/EventCollection.php | EventCollection.add | public function add(Closure $event, $checker = null)
{
$this->events[] = !is_null($checker) ? new Event($event, $checker)
: new Event($event, function () {
});
return $this;
} | php | public function add(Closure $event, $checker = null)
{
$this->events[] = !is_null($checker) ? new Event($event, $checker)
: new Event($event, function () {
});
return $this;
} | [
"public",
"function",
"add",
"(",
"Closure",
"$",
"event",
",",
"$",
"checker",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"events",
"[",
"]",
"=",
"!",
"is_null",
"(",
"$",
"checker",
")",
"?",
"new",
"Event",
"(",
"$",
"event",
",",
"$",
"checke... | Add new event to collection
@param Closure $event
@param Closure|null $checker
@return \TelegramBot\Api\Events\EventCollection | [
"Add",
"new",
"event",
"to",
"collection"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/Events/EventCollection.php#L47-L54 |
TelegramBot/Api | src/Events/Event.php | Event.executeChecker | public function executeChecker(Update $message)
{
if (is_callable($this->checker)) {
return call_user_func($this->checker, $message);
}
return false;
} | php | public function executeChecker(Update $message)
{
if (is_callable($this->checker)) {
return call_user_func($this->checker, $message);
}
return false;
} | [
"public",
"function",
"executeChecker",
"(",
"Update",
"$",
"message",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"checker",
")",
")",
"{",
"return",
"call_user_func",
"(",
"$",
"this",
"->",
"checker",
",",
"$",
"message",
")",
";",
"... | @param \TelegramBot\Api\Types\Update
@return mixed | [
"@param",
"\\",
"TelegramBot",
"\\",
"Api",
"\\",
"Types",
"\\",
"Update"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/Events/Event.php#L53-L60 |
TelegramBot/Api | src/Events/Event.php | Event.executeAction | public function executeAction(Update $message)
{
if (is_callable($this->action)) {
return call_user_func($this->action, $message);
}
return false;
} | php | public function executeAction(Update $message)
{
if (is_callable($this->action)) {
return call_user_func($this->action, $message);
}
return false;
} | [
"public",
"function",
"executeAction",
"(",
"Update",
"$",
"message",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"action",
")",
")",
"{",
"return",
"call_user_func",
"(",
"$",
"this",
"->",
"action",
",",
"$",
"message",
")",
";",
"}",... | @param \TelegramBot\Api\Types\Update
@return mixed | [
"@param",
"\\",
"TelegramBot",
"\\",
"Api",
"\\",
"Types",
"\\",
"Update"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/Events/Event.php#L67-L74 |
TelegramBot/Api | src/Client.php | Client.command | public function command($name, Closure $action)
{
return $this->on(self::getEvent($action), self::getChecker($name));
} | php | public function command($name, Closure $action)
{
return $this->on(self::getEvent($action), self::getChecker($name));
} | [
"public",
"function",
"command",
"(",
"$",
"name",
",",
"Closure",
"$",
"action",
")",
"{",
"return",
"$",
"this",
"->",
"on",
"(",
"self",
"::",
"getEvent",
"(",
"$",
"action",
")",
",",
"self",
"::",
"getChecker",
"(",
"$",
"name",
")",
")",
";",... | Use this method to add command. Parameters will be automatically parsed and passed to closure.
@param string $name
@param \Closure $action
@return \TelegramBot\Api\Client | [
"Use",
"this",
"method",
"to",
"add",
"command",
".",
"Parameters",
"will",
"be",
"automatically",
"parsed",
"and",
"passed",
"to",
"closure",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/Client.php#L52-L55 |
TelegramBot/Api | src/Client.php | Client.on | public function on(Closure $event, Closure $checker = null)
{
$this->events->add($event, $checker);
return $this;
} | php | public function on(Closure $event, Closure $checker = null)
{
$this->events->add($event, $checker);
return $this;
} | [
"public",
"function",
"on",
"(",
"Closure",
"$",
"event",
",",
"Closure",
"$",
"checker",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"events",
"->",
"add",
"(",
"$",
"event",
",",
"$",
"checker",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Use this method to add an event.
If second closure will return true (or if you are passed null instead of closure), first one will be executed.
@param \Closure $event
@param \Closure|null $checker
@return \TelegramBot\Api\Client | [
"Use",
"this",
"method",
"to",
"add",
"an",
"event",
".",
"If",
"second",
"closure",
"will",
"return",
"true",
"(",
"or",
"if",
"you",
"are",
"passed",
"null",
"instead",
"of",
"closure",
")",
"first",
"one",
"will",
"be",
"executed",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/Client.php#L106-L111 |
TelegramBot/Api | src/Client.php | Client.run | public function run()
{
if ($data = BotApi::jsonValidate($this->getRawBody(), true)) {
$this->handle([Update::fromResponse($data)]);
}
} | php | public function run()
{
if ($data = BotApi::jsonValidate($this->getRawBody(), true)) {
$this->handle([Update::fromResponse($data)]);
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"$",
"data",
"=",
"BotApi",
"::",
"jsonValidate",
"(",
"$",
"this",
"->",
"getRawBody",
"(",
")",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"handle",
"(",
"[",
"Update",
"::",
"fromRespons... | Webhook handler
@return array
@throws \TelegramBot\Api\InvalidJsonException | [
"Webhook",
"handler"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/Client.php#L132-L137 |
TelegramBot/Api | src/Client.php | Client.getEvent | protected static function getEvent(Closure $action)
{
return function (Update $update) use ($action) {
$message = $update->getMessage();
if (!$message) {
return true;
}
preg_match(self::REGEXP, $message->getText(), $matches);
if (... | php | protected static function getEvent(Closure $action)
{
return function (Update $update) use ($action) {
$message = $update->getMessage();
if (!$message) {
return true;
}
preg_match(self::REGEXP, $message->getText(), $matches);
if (... | [
"protected",
"static",
"function",
"getEvent",
"(",
"Closure",
"$",
"action",
")",
"{",
"return",
"function",
"(",
"Update",
"$",
"update",
")",
"use",
"(",
"$",
"action",
")",
"{",
"$",
"message",
"=",
"$",
"update",
"->",
"getMessage",
"(",
")",
";",... | Returns event function to handling the command.
@param \Closure $action
@return \Closure | [
"Returns",
"event",
"function",
"to",
"handling",
"the",
"command",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/Client.php#L151-L177 |
TelegramBot/Api | src/Client.php | Client.getChecker | protected static function getChecker($name)
{
return function (Update $update) use ($name) {
$message = $update->getMessage();
if (is_null($message) || !strlen($message->getText())) {
return false;
}
preg_match(self::REGEXP, $message->getText(... | php | protected static function getChecker($name)
{
return function (Update $update) use ($name) {
$message = $update->getMessage();
if (is_null($message) || !strlen($message->getText())) {
return false;
}
preg_match(self::REGEXP, $message->getText(... | [
"protected",
"static",
"function",
"getChecker",
"(",
"$",
"name",
")",
"{",
"return",
"function",
"(",
"Update",
"$",
"update",
")",
"use",
"(",
"$",
"name",
")",
"{",
"$",
"message",
"=",
"$",
"update",
"->",
"getMessage",
"(",
")",
";",
"if",
"(",... | Returns check function to handling the command.
@param string $name
@return \Closure | [
"Returns",
"check",
"function",
"to",
"handling",
"the",
"command",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/Client.php#L290-L302 |
TelegramBot/Api | src/BotApi.php | BotApi.call | public function call($method, array $data = null)
{
$options = $this->proxySettings + [
CURLOPT_URL => $this->getUrl().'/'.$method,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => null,
CURLOPT_POSTFIELDS => null,
CURLOPT_TIMEOUT => 5,
];
... | php | public function call($method, array $data = null)
{
$options = $this->proxySettings + [
CURLOPT_URL => $this->getUrl().'/'.$method,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => null,
CURLOPT_POSTFIELDS => null,
CURLOPT_TIMEOUT => 5,
];
... | [
"public",
"function",
"call",
"(",
"$",
"method",
",",
"array",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"proxySettings",
"+",
"[",
"CURLOPT_URL",
"=>",
"$",
"this",
"->",
"getUrl",
"(",
")",
".",
"'/'",
".",
"$",... | Call method
@param string $method
@param array|null $data
@return mixed
@throws \TelegramBot\Api\Exception
@throws \TelegramBot\Api\HttpException
@throws \TelegramBot\Api\InvalidJsonException | [
"Call",
"method"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L208-L242 |
TelegramBot/Api | src/BotApi.php | BotApi.executeCurl | protected function executeCurl(array $options)
{
curl_setopt_array($this->curl, $options);
$result = curl_exec($this->curl);
self::curlValidate($this->curl, $result);
if ($result === false) {
throw new HttpException(curl_error($this->curl), curl_errno($this->curl));
... | php | protected function executeCurl(array $options)
{
curl_setopt_array($this->curl, $options);
$result = curl_exec($this->curl);
self::curlValidate($this->curl, $result);
if ($result === false) {
throw new HttpException(curl_error($this->curl), curl_errno($this->curl));
... | [
"protected",
"function",
"executeCurl",
"(",
"array",
"$",
"options",
")",
"{",
"curl_setopt_array",
"(",
"$",
"this",
"->",
"curl",
",",
"$",
"options",
")",
";",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"this",
"->",
"curl",
")",
";",
"self",
"::",... | curl_exec wrapper for response validation
@param array $options
@return string
@throws \TelegramBot\Api\HttpException | [
"curl_exec",
"wrapper",
"for",
"response",
"validation"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L253-L264 |
TelegramBot/Api | src/BotApi.php | BotApi.curlValidate | public static function curlValidate($curl, $response = null)
{
$json = json_decode($response, true)?: [];
if (($httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE))
&& !in_array($httpCode, [self::DEFAULT_STATUS_CODE, self::NOT_MODIFIED_STATUS_CODE])
) {
$errorDescripti... | php | public static function curlValidate($curl, $response = null)
{
$json = json_decode($response, true)?: [];
if (($httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE))
&& !in_array($httpCode, [self::DEFAULT_STATUS_CODE, self::NOT_MODIFIED_STATUS_CODE])
) {
$errorDescripti... | [
"public",
"static",
"function",
"curlValidate",
"(",
"$",
"curl",
",",
"$",
"response",
"=",
"null",
")",
"{",
"$",
"json",
"=",
"json_decode",
"(",
"$",
"response",
",",
"true",
")",
"?",
":",
"[",
"]",
";",
"if",
"(",
"(",
"$",
"httpCode",
"=",
... | Response validation
@param resource $curl
@param string $response
@throws HttpException | [
"Response",
"validation"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L273-L283 |
TelegramBot/Api | src/BotApi.php | BotApi.jsonValidate | public static function jsonValidate($jsonString, $asArray)
{
$json = json_decode($jsonString, $asArray);
if (json_last_error() != JSON_ERROR_NONE) {
throw new InvalidJsonException(json_last_error_msg(), json_last_error());
}
return $json;
} | php | public static function jsonValidate($jsonString, $asArray)
{
$json = json_decode($jsonString, $asArray);
if (json_last_error() != JSON_ERROR_NONE) {
throw new InvalidJsonException(json_last_error_msg(), json_last_error());
}
return $json;
} | [
"public",
"static",
"function",
"jsonValidate",
"(",
"$",
"jsonString",
",",
"$",
"asArray",
")",
"{",
"$",
"json",
"=",
"json_decode",
"(",
"$",
"jsonString",
",",
"$",
"asArray",
")",
";",
"if",
"(",
"json_last_error",
"(",
")",
"!=",
"JSON_ERROR_NONE",
... | JSON validation
@param string $jsonString
@param boolean $asArray
@return object|array
@throws \TelegramBot\Api\InvalidJsonException | [
"JSON",
"validation"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L294-L303 |
TelegramBot/Api | src/BotApi.php | BotApi.sendMessage | public function sendMessage(
$chatId,
$text,
$parseMode = null,
$disablePreview = false,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false
) {
return Message::fromResponse($this->call('sendMessage', [
'chat_id' => ... | php | public function sendMessage(
$chatId,
$text,
$parseMode = null,
$disablePreview = false,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false
) {
return Message::fromResponse($this->call('sendMessage', [
'chat_id' => ... | [
"public",
"function",
"sendMessage",
"(",
"$",
"chatId",
",",
"$",
"text",
",",
"$",
"parseMode",
"=",
"null",
",",
"$",
"disablePreview",
"=",
"false",
",",
"$",
"replyToMessageId",
"=",
"null",
",",
"$",
"replyMarkup",
"=",
"null",
",",
"$",
"disableNo... | Use this method to send text messages. On success, the sent \TelegramBot\Api\Types\Message is returned.
@param int|string $chatId
@param string $text
@param string|null $parseMode
@param bool $disablePreview
@param int|null $replyToMessageId
@param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|
Ty... | [
"Use",
"this",
"method",
"to",
"send",
"text",
"messages",
".",
"On",
"success",
"the",
"sent",
"\\",
"TelegramBot",
"\\",
"Api",
"\\",
"Types",
"\\",
"Message",
"is",
"returned",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L321-L339 |
TelegramBot/Api | src/BotApi.php | BotApi.sendContact | public function sendContact(
$chatId,
$phoneNumber,
$firstName,
$lastName = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false
) {
return Message::fromResponse($this->call('sendContact', [
'chat_id' => $chatId... | php | public function sendContact(
$chatId,
$phoneNumber,
$firstName,
$lastName = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false
) {
return Message::fromResponse($this->call('sendContact', [
'chat_id' => $chatId... | [
"public",
"function",
"sendContact",
"(",
"$",
"chatId",
",",
"$",
"phoneNumber",
",",
"$",
"firstName",
",",
"$",
"lastName",
"=",
"null",
",",
"$",
"replyToMessageId",
"=",
"null",
",",
"$",
"replyMarkup",
"=",
"null",
",",
"$",
"disableNotification",
"=... | Use this method to send phone contacts
@param int|string $chatId chat_id or @channel_name
@param string $phoneNumber
@param string $firstName
@param string $lastName
@param int|null $replyToMessageId
@param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|
Types\ReplyKeyboardRemove|null $replyMarkup
... | [
"Use",
"this",
"method",
"to",
"send",
"phone",
"contacts"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L356-L374 |
TelegramBot/Api | src/BotApi.php | BotApi.getUserProfilePhotos | public function getUserProfilePhotos($userId, $offset = 0, $limit = 100)
{
return UserProfilePhotos::fromResponse($this->call('getUserProfilePhotos', [
'user_id' => (int)$userId,
'offset' => (int)$offset,
'limit' => (int)$limit,
]));
} | php | public function getUserProfilePhotos($userId, $offset = 0, $limit = 100)
{
return UserProfilePhotos::fromResponse($this->call('getUserProfilePhotos', [
'user_id' => (int)$userId,
'offset' => (int)$offset,
'limit' => (int)$limit,
]));
} | [
"public",
"function",
"getUserProfilePhotos",
"(",
"$",
"userId",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"limit",
"=",
"100",
")",
"{",
"return",
"UserProfilePhotos",
"::",
"fromResponse",
"(",
"$",
"this",
"->",
"call",
"(",
"'getUserProfilePhotos'",
",",
... | Use this method to get a list of profile pictures for a user.
@param int $userId
@param int $offset
@param int $limit
@return \TelegramBot\Api\Types\UserProfilePhotos
@throws \TelegramBot\Api\Exception | [
"Use",
"this",
"method",
"to",
"get",
"a",
"list",
"of",
"profile",
"pictures",
"for",
"a",
"user",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L412-L419 |
TelegramBot/Api | src/BotApi.php | BotApi.getUpdates | public function getUpdates($offset = 0, $limit = 100, $timeout = 0)
{
$updates = ArrayOfUpdates::fromResponse($this->call('getUpdates', [
'offset' => $offset,
'limit' => $limit,
'timeout' => $timeout,
]));
if ($this->tracker instanceof Botan) {
... | php | public function getUpdates($offset = 0, $limit = 100, $timeout = 0)
{
$updates = ArrayOfUpdates::fromResponse($this->call('getUpdates', [
'offset' => $offset,
'limit' => $limit,
'timeout' => $timeout,
]));
if ($this->tracker instanceof Botan) {
... | [
"public",
"function",
"getUpdates",
"(",
"$",
"offset",
"=",
"0",
",",
"$",
"limit",
"=",
"100",
",",
"$",
"timeout",
"=",
"0",
")",
"{",
"$",
"updates",
"=",
"ArrayOfUpdates",
"::",
"fromResponse",
"(",
"$",
"this",
"->",
"call",
"(",
"'getUpdates'",
... | Use this method to receive incoming updates using long polling.
An Array of Update objects is returned.
Notes
1. This method will not work if an outgoing webhook is set up.
2. In order to avoid getting duplicate updates, recalculate offset after each server response.
@param int $offset
@param int $limit
@param int $t... | [
"Use",
"this",
"method",
"to",
"receive",
"incoming",
"updates",
"using",
"long",
"polling",
".",
"An",
"Array",
"of",
"Update",
"objects",
"is",
"returned",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L469-L484 |
TelegramBot/Api | src/BotApi.php | BotApi.sendLocation | public function sendLocation(
$chatId,
$latitude,
$longitude,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false,
$livePeriod = null
) {
return Message::fromResponse($this->call('sendLocation', [
'chat_id' ... | php | public function sendLocation(
$chatId,
$latitude,
$longitude,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false,
$livePeriod = null
) {
return Message::fromResponse($this->call('sendLocation', [
'chat_id' ... | [
"public",
"function",
"sendLocation",
"(",
"$",
"chatId",
",",
"$",
"latitude",
",",
"$",
"longitude",
",",
"$",
"replyToMessageId",
"=",
"null",
",",
"$",
"replyMarkup",
"=",
"null",
",",
"$",
"disableNotification",
"=",
"false",
",",
"$",
"livePeriod",
"... | Use this method to send point on the map. On success, the sent Message is returned.
@param int|string $chatId
@param float $latitude
@param float ... | [
"Use",
"this",
"method",
"to",
"send",
"point",
"on",
"the",
"map",
".",
"On",
"success",
"the",
"sent",
"Message",
"is",
"returned",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L500-L518 |
TelegramBot/Api | src/BotApi.php | BotApi.editMessageLiveLocation | public function editMessageLiveLocation(
$chatId,
$messageId,
$inlineMessageId,
$latitude,
$longitude,
$replyMarkup = null
) {
return Message::fromResponse($this->call('sendLocation', [
'chat_id' => $chatId,
'message_id' ... | php | public function editMessageLiveLocation(
$chatId,
$messageId,
$inlineMessageId,
$latitude,
$longitude,
$replyMarkup = null
) {
return Message::fromResponse($this->call('sendLocation', [
'chat_id' => $chatId,
'message_id' ... | [
"public",
"function",
"editMessageLiveLocation",
"(",
"$",
"chatId",
",",
"$",
"messageId",
",",
"$",
"inlineMessageId",
",",
"$",
"latitude",
",",
"$",
"longitude",
",",
"$",
"replyMarkup",
"=",
"null",
")",
"{",
"return",
"Message",
"::",
"fromResponse",
"... | Use this method to edit live location messages sent by the bot or via the bot (for inline bots).
@param int|string $chatId
@param int $messageId
@param string ... | [
"Use",
"this",
"method",
"to",
"edit",
"live",
"location",
"messages",
"sent",
"by",
"the",
"bot",
"or",
"via",
"the",
"bot",
"(",
"for",
"inline",
"bots",
")",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L532-L548 |
TelegramBot/Api | src/BotApi.php | BotApi.stopMessageLiveLocation | public function stopMessageLiveLocation(
$chatId,
$messageId,
$inlineMessageId,
$replyMarkup = null
) {
return Message::fromResponse($this->call('sendLocation', [
'chat_id' => $chatId,
'message_id' => $messageId,
'inline_me... | php | public function stopMessageLiveLocation(
$chatId,
$messageId,
$inlineMessageId,
$replyMarkup = null
) {
return Message::fromResponse($this->call('sendLocation', [
'chat_id' => $chatId,
'message_id' => $messageId,
'inline_me... | [
"public",
"function",
"stopMessageLiveLocation",
"(",
"$",
"chatId",
",",
"$",
"messageId",
",",
"$",
"inlineMessageId",
",",
"$",
"replyMarkup",
"=",
"null",
")",
"{",
"return",
"Message",
"::",
"fromResponse",
"(",
"$",
"this",
"->",
"call",
"(",
"'sendLoc... | Use this method to stop updating a live location message sent by the bot or via the bot (for inline bots) before
live_period expires.
@param int|string $chatId
@param int $messageId
@param s... | [
"Use",
"this",
"method",
"to",
"stop",
"updating",
"a",
"live",
"location",
"message",
"sent",
"by",
"the",
"bot",
"or",
"via",
"the",
"bot",
"(",
"for",
"inline",
"bots",
")",
"before",
"live_period",
"expires",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L561-L573 |
TelegramBot/Api | src/BotApi.php | BotApi.sendVenue | public function sendVenue(
$chatId,
$latitude,
$longitude,
$title,
$address,
$foursquareId = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false
) {
return Message::fromResponse($this->call('sendVenue', [
... | php | public function sendVenue(
$chatId,
$latitude,
$longitude,
$title,
$address,
$foursquareId = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false
) {
return Message::fromResponse($this->call('sendVenue', [
... | [
"public",
"function",
"sendVenue",
"(",
"$",
"chatId",
",",
"$",
"latitude",
",",
"$",
"longitude",
",",
"$",
"title",
",",
"$",
"address",
",",
"$",
"foursquareId",
"=",
"null",
",",
"$",
"replyToMessageId",
"=",
"null",
",",
"$",
"replyMarkup",
"=",
... | Use this method to send information about a venue. On success, the sent Message is returned.
@param int|string $chatId chat_id or @channel_name
@param float $latitude
@param float $longitude
@param string $title
@param string $address
@param string|null $foursquareId
@param int|null $replyToMessageId
@param Types\Repl... | [
"Use",
"this",
"method",
"to",
"send",
"information",
"about",
"a",
"venue",
".",
"On",
"success",
"the",
"sent",
"Message",
"is",
"returned",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L592-L614 |
TelegramBot/Api | src/BotApi.php | BotApi.sendSticker | public function sendSticker(
$chatId,
$sticker,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false
) {
return Message::fromResponse($this->call('sendSticker', [
'chat_id' => $chatId,
'sticker' => $sticker,
'... | php | public function sendSticker(
$chatId,
$sticker,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false
) {
return Message::fromResponse($this->call('sendSticker', [
'chat_id' => $chatId,
'sticker' => $sticker,
'... | [
"public",
"function",
"sendSticker",
"(",
"$",
"chatId",
",",
"$",
"sticker",
",",
"$",
"replyToMessageId",
"=",
"null",
",",
"$",
"replyMarkup",
"=",
"null",
",",
"$",
"disableNotification",
"=",
"false",
")",
"{",
"return",
"Message",
"::",
"fromResponse",... | Use this method to send .webp stickers. On success, the sent Message is returned.
@param int|string $chatId chat_id or @channel_name
@param \CURLFile|string $sticker
@param int|null $replyToMessageId
@param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|
Types\ReplyKeyboardRemove|null $replyMarkup
... | [
"Use",
"this",
"method",
"to",
"send",
".",
"webp",
"stickers",
".",
"On",
"success",
"the",
"sent",
"Message",
"is",
"returned",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L630-L644 |
TelegramBot/Api | src/BotApi.php | BotApi.sendVideo | public function sendVideo(
$chatId,
$video,
$duration = null,
$caption = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false,
$supportsStreaming = false,
$parseMode = null
) {
return Message::fromResponse($... | php | public function sendVideo(
$chatId,
$video,
$duration = null,
$caption = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false,
$supportsStreaming = false,
$parseMode = null
) {
return Message::fromResponse($... | [
"public",
"function",
"sendVideo",
"(",
"$",
"chatId",
",",
"$",
"video",
",",
"$",
"duration",
"=",
"null",
",",
"$",
"caption",
"=",
"null",
",",
"$",
"replyToMessageId",
"=",
"null",
",",
"$",
"replyMarkup",
"=",
"null",
",",
"$",
"disableNotification... | Use this method to send video files,
Telegram clients support mp4 videos (other formats may be sent as Document).
On success, the sent Message is returned.
@param int|string $chatId chat_id or @channel_name
@param \CURLFile|string $video
@param int|null $duration
@param string|null $caption
@param int|null $replyToMes... | [
"Use",
"this",
"method",
"to",
"send",
"video",
"files",
"Telegram",
"clients",
"support",
"mp4",
"videos",
"(",
"other",
"formats",
"may",
"be",
"sent",
"as",
"Document",
")",
".",
"On",
"success",
"the",
"sent",
"Message",
"is",
"returned",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L666-L688 |
TelegramBot/Api | src/BotApi.php | BotApi.sendVoice | public function sendVoice(
$chatId,
$voice,
$duration = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false,
$parseMode = null
) {
return Message::fromResponse($this->call('sendVoice', [
'chat_id' => $chatId,
... | php | public function sendVoice(
$chatId,
$voice,
$duration = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false,
$parseMode = null
) {
return Message::fromResponse($this->call('sendVoice', [
'chat_id' => $chatId,
... | [
"public",
"function",
"sendVoice",
"(",
"$",
"chatId",
",",
"$",
"voice",
",",
"$",
"duration",
"=",
"null",
",",
"$",
"replyToMessageId",
"=",
"null",
",",
"$",
"replyMarkup",
"=",
"null",
",",
"$",
"disableNotification",
"=",
"false",
",",
"$",
"parseM... | Use this method to send audio files,
if you want Telegram clients to display the file as a playable voice message.
For this to work, your audio must be in an .ogg file encoded with OPUS
(other formats may be sent as Audio or Document).
On success, the sent Message is returned.
Bots can currently send voice messages of ... | [
"Use",
"this",
"method",
"to",
"send",
"audio",
"files",
"if",
"you",
"want",
"Telegram",
"clients",
"to",
"display",
"the",
"file",
"as",
"a",
"playable",
"voice",
"message",
".",
"For",
"this",
"to",
"work",
"your",
"audio",
"must",
"be",
"in",
"an",
... | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L711-L729 |
TelegramBot/Api | src/BotApi.php | BotApi.forwardMessage | public function forwardMessage($chatId, $fromChatId, $messageId, $disableNotification = false)
{
return Message::fromResponse($this->call('forwardMessage', [
'chat_id' => $chatId,
'from_chat_id' => $fromChatId,
'message_id' => (int)$messageId,
'disable_notific... | php | public function forwardMessage($chatId, $fromChatId, $messageId, $disableNotification = false)
{
return Message::fromResponse($this->call('forwardMessage', [
'chat_id' => $chatId,
'from_chat_id' => $fromChatId,
'message_id' => (int)$messageId,
'disable_notific... | [
"public",
"function",
"forwardMessage",
"(",
"$",
"chatId",
",",
"$",
"fromChatId",
",",
"$",
"messageId",
",",
"$",
"disableNotification",
"=",
"false",
")",
"{",
"return",
"Message",
"::",
"fromResponse",
"(",
"$",
"this",
"->",
"call",
"(",
"'forwardMessa... | Use this method to forward messages of any kind. On success, the sent Message is returned.
@param int|string $chatId chat_id or @channel_name
@param int $fromChatId
@param int $messageId
@param bool $disableNotification
@return \TelegramBot\Api\Types\Message
@throws \TelegramBot\Api\InvalidArgumentException
@throws \... | [
"Use",
"this",
"method",
"to",
"forward",
"messages",
"of",
"any",
"kind",
".",
"On",
"success",
"the",
"sent",
"Message",
"is",
"returned",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L743-L751 |
TelegramBot/Api | src/BotApi.php | BotApi.sendAudio | public function sendAudio(
$chatId,
$audio,
$duration = null,
$performer = null,
$title = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false,
$parseMode = null
) {
return Message::fromResponse($this->call(... | php | public function sendAudio(
$chatId,
$audio,
$duration = null,
$performer = null,
$title = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false,
$parseMode = null
) {
return Message::fromResponse($this->call(... | [
"public",
"function",
"sendAudio",
"(",
"$",
"chatId",
",",
"$",
"audio",
",",
"$",
"duration",
"=",
"null",
",",
"$",
"performer",
"=",
"null",
",",
"$",
"title",
"=",
"null",
",",
"$",
"replyToMessageId",
"=",
"null",
",",
"$",
"replyMarkup",
"=",
... | Use this method to send audio files,
if you want Telegram clients to display them in the music player.
Your audio must be in the .mp3 format.
On success, the sent Message is returned.
Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
For backward compatibility, when t... | [
"Use",
"this",
"method",
"to",
"send",
"audio",
"files",
"if",
"you",
"want",
"Telegram",
"clients",
"to",
"display",
"them",
"in",
"the",
"music",
"player",
".",
"Your",
"audio",
"must",
"be",
"in",
"the",
".",
"mp3",
"format",
".",
"On",
"success",
"... | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L784-L806 |
TelegramBot/Api | src/BotApi.php | BotApi.sendPhoto | public function sendPhoto(
$chatId,
$photo,
$caption = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false,
$parseMode = null
) {
return Message::fromResponse($this->call('sendPhoto', [
'chat_id' => $chatId,
... | php | public function sendPhoto(
$chatId,
$photo,
$caption = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false,
$parseMode = null
) {
return Message::fromResponse($this->call('sendPhoto', [
'chat_id' => $chatId,
... | [
"public",
"function",
"sendPhoto",
"(",
"$",
"chatId",
",",
"$",
"photo",
",",
"$",
"caption",
"=",
"null",
",",
"$",
"replyToMessageId",
"=",
"null",
",",
"$",
"replyMarkup",
"=",
"null",
",",
"$",
"disableNotification",
"=",
"false",
",",
"$",
"parseMo... | Use this method to send photos. On success, the sent Message is returned.
@param int|string $chatId chat_id or @channel_name
@param \CURLFile|string $photo
@param string|null $caption
@param int|null $replyToMessageId
@param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|
Types\ReplyKeyboardRemove|... | [
"Use",
"this",
"method",
"to",
"send",
"photos",
".",
"On",
"success",
"the",
"sent",
"Message",
"is",
"returned",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L824-L842 |
TelegramBot/Api | src/BotApi.php | BotApi.sendDocument | public function sendDocument(
$chatId,
$document,
$caption = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false,
$parseMode = null
) {
return Message::fromResponse($this->call('sendDocument', [
'chat_id' => $c... | php | public function sendDocument(
$chatId,
$document,
$caption = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false,
$parseMode = null
) {
return Message::fromResponse($this->call('sendDocument', [
'chat_id' => $c... | [
"public",
"function",
"sendDocument",
"(",
"$",
"chatId",
",",
"$",
"document",
",",
"$",
"caption",
"=",
"null",
",",
"$",
"replyToMessageId",
"=",
"null",
",",
"$",
"replyMarkup",
"=",
"null",
",",
"$",
"disableNotification",
"=",
"false",
",",
"$",
"p... | Use this method to send general files. On success, the sent Message is returned.
Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
@param int|string $chatId chat_id or @channel_name
@param \CURLFile|string $document
@param string|null $caption
@param int|null $r... | [
"Use",
"this",
"method",
"to",
"send",
"general",
"files",
".",
"On",
"success",
"the",
"sent",
"Message",
"is",
"returned",
".",
"Bots",
"can",
"currently",
"send",
"files",
"of",
"any",
"type",
"of",
"up",
"to",
"50",
"MB",
"in",
"size",
"this",
"lim... | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L861-L879 |
TelegramBot/Api | src/BotApi.php | BotApi.downloadFile | public function downloadFile($fileId)
{
$file = $this->getFile($fileId);
$options = [
CURLOPT_HEADER => 0,
CURLOPT_HTTPGET => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $this->getFileUrl().'/'.$file->getFilePath(),
];
return $this-... | php | public function downloadFile($fileId)
{
$file = $this->getFile($fileId);
$options = [
CURLOPT_HEADER => 0,
CURLOPT_HTTPGET => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $this->getFileUrl().'/'.$file->getFilePath(),
];
return $this-... | [
"public",
"function",
"downloadFile",
"(",
"$",
"fileId",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getFile",
"(",
"$",
"fileId",
")",
";",
"$",
"options",
"=",
"[",
"CURLOPT_HEADER",
"=>",
"0",
",",
"CURLOPT_HTTPGET",
"=>",
"1",
",",
"CURLOPT_RE... | Get file contents via cURL
@param $fileId
@return string
@throws \TelegramBot\Api\HttpException | [
"Get",
"file",
"contents",
"via",
"cURL"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L910-L921 |
TelegramBot/Api | src/BotApi.php | BotApi.answerInlineQuery | public function answerInlineQuery(
$inlineQueryId,
$results,
$cacheTime = 300,
$isPersonal = false,
$nextOffset = '',
$switchPmText = null,
$switchPmParameter = null
) {
$results = array_map(function ($item) {
/* @var AbstractInlineQueryRes... | php | public function answerInlineQuery(
$inlineQueryId,
$results,
$cacheTime = 300,
$isPersonal = false,
$nextOffset = '',
$switchPmText = null,
$switchPmParameter = null
) {
$results = array_map(function ($item) {
/* @var AbstractInlineQueryRes... | [
"public",
"function",
"answerInlineQuery",
"(",
"$",
"inlineQueryId",
",",
"$",
"results",
",",
"$",
"cacheTime",
"=",
"300",
",",
"$",
"isPersonal",
"=",
"false",
",",
"$",
"nextOffset",
"=",
"''",
",",
"$",
"switchPmText",
"=",
"null",
",",
"$",
"switc... | Use this method to send answers to an inline query. On success, True is returned.
No more than 50 results per query are allowed.
@param string $inlineQueryId
@param AbstractInlineQueryResult[] $results
@param int $cacheTime
@param bool $isPersonal
@param string $nextOffset
@param string $switchPmText
@param string $sw... | [
"Use",
"this",
"method",
"to",
"send",
"answers",
"to",
"an",
"inline",
"query",
".",
"On",
"success",
"True",
"is",
"returned",
".",
"No",
"more",
"than",
"50",
"results",
"per",
"query",
"are",
"allowed",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L938-L961 |
TelegramBot/Api | src/BotApi.php | BotApi.kickChatMember | public function kickChatMember($chatId, $userId, $untilDate = null)
{
return $this->call('kickChatMember', [
'chat_id' => $chatId,
'user_id' => $userId,
'until_date' => $untilDate
]);
} | php | public function kickChatMember($chatId, $userId, $untilDate = null)
{
return $this->call('kickChatMember', [
'chat_id' => $chatId,
'user_id' => $userId,
'until_date' => $untilDate
]);
} | [
"public",
"function",
"kickChatMember",
"(",
"$",
"chatId",
",",
"$",
"userId",
",",
"$",
"untilDate",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"call",
"(",
"'kickChatMember'",
",",
"[",
"'chat_id'",
"=>",
"$",
"chatId",
",",
"'user_id'",
"=>"... | Use this method to kick a user from a group or a supergroup.
In the case of supergroups, the user will not be able to return to the group
on their own using invite links, etc., unless unbanned first.
The bot must be an administrator in the group for this to work. Returns True on success.
@param int|string $chatId Uniq... | [
"Use",
"this",
"method",
"to",
"kick",
"a",
"user",
"from",
"a",
"group",
"or",
"a",
"supergroup",
".",
"In",
"the",
"case",
"of",
"supergroups",
"the",
"user",
"will",
"not",
"be",
"able",
"to",
"return",
"to",
"the",
"group",
"on",
"their",
"own",
... | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L978-L985 |
TelegramBot/Api | src/BotApi.php | BotApi.answerCallbackQuery | public function answerCallbackQuery($callbackQueryId, $text = null, $showAlert = false)
{
return $this->call('answerCallbackQuery', [
'callback_query_id' => $callbackQueryId,
'text' => $text,
'show_alert' => (bool)$showAlert,
]);
} | php | public function answerCallbackQuery($callbackQueryId, $text = null, $showAlert = false)
{
return $this->call('answerCallbackQuery', [
'callback_query_id' => $callbackQueryId,
'text' => $text,
'show_alert' => (bool)$showAlert,
]);
} | [
"public",
"function",
"answerCallbackQuery",
"(",
"$",
"callbackQueryId",
",",
"$",
"text",
"=",
"null",
",",
"$",
"showAlert",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"call",
"(",
"'answerCallbackQuery'",
",",
"[",
"'callback_query_id'",
"=>",
... | Use this method to send answers to callback queries sent from inline keyboards.
The answer will be displayed to the user as a notification at the top of the chat screen or as an alert.
@param $callbackQueryId
@param null $text
@param bool $showAlert
@return bool | [
"Use",
"this",
"method",
"to",
"send",
"answers",
"to",
"callback",
"queries",
"sent",
"from",
"inline",
"keyboards",
".",
"The",
"answer",
"will",
"be",
"displayed",
"to",
"the",
"user",
"as",
"a",
"notification",
"at",
"the",
"top",
"of",
"the",
"chat",
... | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L1016-L1023 |
TelegramBot/Api | src/BotApi.php | BotApi.editMessageText | public function editMessageText(
$chatId,
$messageId,
$text,
$parseMode = null,
$disablePreview = false,
$replyMarkup = null,
$inlineMessageId = null
) {
return Message::fromResponse($this->call('editMessageText', [
'chat_id' => $chatId,
... | php | public function editMessageText(
$chatId,
$messageId,
$text,
$parseMode = null,
$disablePreview = false,
$replyMarkup = null,
$inlineMessageId = null
) {
return Message::fromResponse($this->call('editMessageText', [
'chat_id' => $chatId,
... | [
"public",
"function",
"editMessageText",
"(",
"$",
"chatId",
",",
"$",
"messageId",
",",
"$",
"text",
",",
"$",
"parseMode",
"=",
"null",
",",
"$",
"disablePreview",
"=",
"false",
",",
"$",
"replyMarkup",
"=",
"null",
",",
"$",
"inlineMessageId",
"=",
"n... | Use this method to edit text messages sent by the bot or via the bot
@param int|string $chatId
@param int $messageId
@param string $text
@param string $inlineMessageId
@param string|null $parseMode
@param bool $disablePreview
@param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|
Types\ReplyKeyboar... | [
"Use",
"this",
"method",
"to",
"edit",
"text",
"messages",
"sent",
"by",
"the",
"bot",
"or",
"via",
"the",
"bot"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L1039-L1057 |
TelegramBot/Api | src/BotApi.php | BotApi.editMessageCaption | public function editMessageCaption(
$chatId,
$messageId,
$caption = null,
$replyMarkup = null,
$inlineMessageId = null
) {
return Message::fromResponse($this->call('editMessageCaption', [
'chat_id' => $chatId,
'message_id' => $messageId,
... | php | public function editMessageCaption(
$chatId,
$messageId,
$caption = null,
$replyMarkup = null,
$inlineMessageId = null
) {
return Message::fromResponse($this->call('editMessageCaption', [
'chat_id' => $chatId,
'message_id' => $messageId,
... | [
"public",
"function",
"editMessageCaption",
"(",
"$",
"chatId",
",",
"$",
"messageId",
",",
"$",
"caption",
"=",
"null",
",",
"$",
"replyMarkup",
"=",
"null",
",",
"$",
"inlineMessageId",
"=",
"null",
")",
"{",
"return",
"Message",
"::",
"fromResponse",
"(... | Use this method to edit text messages sent by the bot or via the bot
@param int|string $chatId
@param int $messageId
@param string|null $caption
@param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|
Types\ReplyKeyboardRemove|null $replyMarkup
@param string $inlineMessageId
@return \TelegramBot\Ap... | [
"Use",
"this",
"method",
"to",
"edit",
"text",
"messages",
"sent",
"by",
"the",
"bot",
"or",
"via",
"the",
"bot"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L1073-L1087 |
TelegramBot/Api | src/BotApi.php | BotApi.trackUpdate | public function trackUpdate(Update $update, $eventName = 'Message')
{
if (!in_array($update->getUpdateId(), $this->trackedEvents)) {
$this->trackedEvents[] = $update->getUpdateId();
$this->track($update->getMessage(), $eventName);
if (count($this->trackedEvents) > self:... | php | public function trackUpdate(Update $update, $eventName = 'Message')
{
if (!in_array($update->getUpdateId(), $this->trackedEvents)) {
$this->trackedEvents[] = $update->getUpdateId();
$this->track($update->getMessage(), $eventName);
if (count($this->trackedEvents) > self:... | [
"public",
"function",
"trackUpdate",
"(",
"Update",
"$",
"update",
",",
"$",
"eventName",
"=",
"'Message'",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"update",
"->",
"getUpdateId",
"(",
")",
",",
"$",
"this",
"->",
"trackedEvents",
")",
")",
"{",... | @param \TelegramBot\Api\Types\Update $update
@param string $eventName
@throws \TelegramBot\Api\Exception | [
"@param",
"\\",
"TelegramBot",
"\\",
"Api",
"\\",
"Types",
"\\",
"Update",
"$update",
"@param",
"string",
"$eventName"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L1165-L1176 |
TelegramBot/Api | src/BotApi.php | BotApi.track | public function track(Message $message, $eventName = 'Message')
{
if ($this->tracker instanceof Botan) {
$this->tracker->track($message, $eventName);
}
} | php | public function track(Message $message, $eventName = 'Message')
{
if ($this->tracker instanceof Botan) {
$this->tracker->track($message, $eventName);
}
} | [
"public",
"function",
"track",
"(",
"Message",
"$",
"message",
",",
"$",
"eventName",
"=",
"'Message'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"tracker",
"instanceof",
"Botan",
")",
"{",
"$",
"this",
"->",
"tracker",
"->",
"track",
"(",
"$",
"message"... | Wrapper for tracker
@param \TelegramBot\Api\Types\Message $message
@param string $eventName
@throws \TelegramBot\Api\Exception | [
"Wrapper",
"for",
"tracker"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L1186-L1191 |
TelegramBot/Api | src/BotApi.php | BotApi.sendInvoice | public function sendInvoice(
$chatId,
$title,
$description,
$payload,
$providerToken,
$startParameter,
$currency,
$prices,
$isFlexible = false,
$photoUrl = null,
$photoSize = null,
$photoWidth = null,
$photoHeight = ... | php | public function sendInvoice(
$chatId,
$title,
$description,
$payload,
$providerToken,
$startParameter,
$currency,
$prices,
$isFlexible = false,
$photoUrl = null,
$photoSize = null,
$photoWidth = null,
$photoHeight = ... | [
"public",
"function",
"sendInvoice",
"(",
"$",
"chatId",
",",
"$",
"title",
",",
"$",
"description",
",",
"$",
"payload",
",",
"$",
"providerToken",
",",
"$",
"startParameter",
",",
"$",
"currency",
",",
"$",
"prices",
",",
"$",
"isFlexible",
"=",
"false... | Use this method to send invoices. On success, the sent Message is returned.
@param int|string $chatId
@param string $title
@param string $description
@param string $payload
@param string $providerToken
@param string $startParameter
@param string $currency
@param array $prices
@param string|null $photoUrl
@param int|nu... | [
"Use",
"this",
"method",
"to",
"send",
"invoices",
".",
"On",
"success",
"the",
"sent",
"Message",
"is",
"returned",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L1223-L1273 |
TelegramBot/Api | src/BotApi.php | BotApi.answerShippingQuery | public function answerShippingQuery($shippingQueryId, $ok = true, $shipping_options = [], $errorMessage = null)
{
return $this->call('answerShippingQuery', [
'shipping_query_id' => $shippingQueryId,
'ok' => (bool)$ok,
'shipping_options' => json_encode($shipping_options),
... | php | public function answerShippingQuery($shippingQueryId, $ok = true, $shipping_options = [], $errorMessage = null)
{
return $this->call('answerShippingQuery', [
'shipping_query_id' => $shippingQueryId,
'ok' => (bool)$ok,
'shipping_options' => json_encode($shipping_options),
... | [
"public",
"function",
"answerShippingQuery",
"(",
"$",
"shippingQueryId",
",",
"$",
"ok",
"=",
"true",
",",
"$",
"shipping_options",
"=",
"[",
"]",
",",
"$",
"errorMessage",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"call",
"(",
"'answerShippingQ... | If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API
will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries.
On success, True is returned.
@param string $shippingQueryId
@param bool $ok
@param array $shipping_opt... | [
"If",
"you",
"sent",
"an",
"invoice",
"requesting",
"a",
"shipping",
"address",
"and",
"the",
"parameter",
"is_flexible",
"was",
"specified",
"the",
"Bot",
"API",
"will",
"send",
"an",
"Update",
"with",
"a",
"shipping_query",
"field",
"to",
"the",
"bot",
"."... | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L1288-L1296 |
TelegramBot/Api | src/BotApi.php | BotApi.answerPreCheckoutQuery | public function answerPreCheckoutQuery($preCheckoutQueryId, $ok = true, $errorMessage = null)
{
return $this->call('answerPreCheckoutQuery', [
'pre_checkout_query_id' => $preCheckoutQueryId,
'ok' => (bool)$ok,
'error_message' => $errorMessage
]);
} | php | public function answerPreCheckoutQuery($preCheckoutQueryId, $ok = true, $errorMessage = null)
{
return $this->call('answerPreCheckoutQuery', [
'pre_checkout_query_id' => $preCheckoutQueryId,
'ok' => (bool)$ok,
'error_message' => $errorMessage
]);
} | [
"public",
"function",
"answerPreCheckoutQuery",
"(",
"$",
"preCheckoutQueryId",
",",
"$",
"ok",
"=",
"true",
",",
"$",
"errorMessage",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"call",
"(",
"'answerPreCheckoutQuery'",
",",
"[",
"'pre_checkout_query_id'... | Use this method to respond to such pre-checkout queries. On success, True is returned.
Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
@param string $preCheckoutQueryId
@param bool $ok
@param null|string $errorMessage
@return mixed | [
"Use",
"this",
"method",
"to",
"respond",
"to",
"such",
"pre",
"-",
"checkout",
"queries",
".",
"On",
"success",
"True",
"is",
"returned",
".",
"Note",
":",
"The",
"Bot",
"API",
"must",
"receive",
"an",
"answer",
"within",
"10",
"seconds",
"after",
"the"... | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L1308-L1315 |
TelegramBot/Api | src/BotApi.php | BotApi.restrictChatMember | public function restrictChatMember(
$chatId,
$userId,
$untilDate = null,
$canSendMessages = false,
$canSendMediaMessages = false,
$canSendOtherMessages = false,
$canAddWebPagePreviews = false
) {
return $this->call('restrictChatMember', [
'... | php | public function restrictChatMember(
$chatId,
$userId,
$untilDate = null,
$canSendMessages = false,
$canSendMediaMessages = false,
$canSendOtherMessages = false,
$canAddWebPagePreviews = false
) {
return $this->call('restrictChatMember', [
'... | [
"public",
"function",
"restrictChatMember",
"(",
"$",
"chatId",
",",
"$",
"userId",
",",
"$",
"untilDate",
"=",
"null",
",",
"$",
"canSendMessages",
"=",
"false",
",",
"$",
"canSendMediaMessages",
"=",
"false",
",",
"$",
"canSendOtherMessages",
"=",
"false",
... | Use this method to restrict a user in a supergroup.
The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights.
Pass True for all boolean parameters to lift restrictions from a user.
@param string|int $chatId Unique identifier for the target chat or username of the t... | [
"Use",
"this",
"method",
"to",
"restrict",
"a",
"user",
"in",
"a",
"supergroup",
".",
"The",
"bot",
"must",
"be",
"an",
"administrator",
"in",
"the",
"supergroup",
"for",
"this",
"to",
"work",
"and",
"must",
"have",
"the",
"appropriate",
"admin",
"rights",... | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L1338-L1356 |
TelegramBot/Api | src/BotApi.php | BotApi.promoteChatMember | public function promoteChatMember(
$chatId,
$userId,
$canChangeInfo = true,
$canPostMessages = true,
$canEditMessages = true,
$canDeleteMessages = true,
$canInviteUsers = true,
$canRestrictMembers = true,
$canPinMessages = true,
$canPromote... | php | public function promoteChatMember(
$chatId,
$userId,
$canChangeInfo = true,
$canPostMessages = true,
$canEditMessages = true,
$canDeleteMessages = true,
$canInviteUsers = true,
$canRestrictMembers = true,
$canPinMessages = true,
$canPromote... | [
"public",
"function",
"promoteChatMember",
"(",
"$",
"chatId",
",",
"$",
"userId",
",",
"$",
"canChangeInfo",
"=",
"true",
",",
"$",
"canPostMessages",
"=",
"true",
",",
"$",
"canEditMessages",
"=",
"true",
",",
"$",
"canDeleteMessages",
"=",
"true",
",",
... | Use this method to promote or demote a user in a supergroup or a channel.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Pass False for all boolean parameters to demote a user.
@param string|int $chatId Unique identifier for the target chat or username of the ... | [
"Use",
"this",
"method",
"to",
"promote",
"or",
"demote",
"a",
"user",
"in",
"a",
"supergroup",
"or",
"a",
"channel",
".",
"The",
"bot",
"must",
"be",
"an",
"administrator",
"in",
"the",
"chat",
"for",
"this",
"to",
"work",
"and",
"must",
"have",
"the"... | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L1379-L1403 |
TelegramBot/Api | src/BotApi.php | BotApi.pinChatMessage | public function pinChatMessage($chatId, $messageId, $disableNotification = false)
{
return $this->call('pinChatMessage', [
'chat_id' => $chatId,
'message_id' => $messageId,
'disable_notification' => $disableNotification
]);
} | php | public function pinChatMessage($chatId, $messageId, $disableNotification = false)
{
return $this->call('pinChatMessage', [
'chat_id' => $chatId,
'message_id' => $messageId,
'disable_notification' => $disableNotification
]);
} | [
"public",
"function",
"pinChatMessage",
"(",
"$",
"chatId",
",",
"$",
"messageId",
",",
"$",
"disableNotification",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"call",
"(",
"'pinChatMessage'",
",",
"[",
"'chat_id'",
"=>",
"$",
"chatId",
",",
"'mes... | Use this method to pin a message in a supergroup.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
@param string|int $chatId Unique identifier for the target chat or username of the target channel
(in the format @channelusername)
@param int $messageId Identifier... | [
"Use",
"this",
"method",
"to",
"pin",
"a",
"message",
"in",
"a",
"supergroup",
".",
"The",
"bot",
"must",
"be",
"an",
"administrator",
"in",
"the",
"chat",
"for",
"this",
"to",
"work",
"and",
"must",
"have",
"the",
"appropriate",
"admin",
"rights",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L1501-L1508 |
TelegramBot/Api | src/BotApi.php | BotApi.sendVideoNote | public function sendVideoNote(
$chatId,
$videoNote,
$duration = null,
$length = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false
) {
return Message::fromResponse($this->call('sendVideoNote', [
'chat_id' => $... | php | public function sendVideoNote(
$chatId,
$videoNote,
$duration = null,
$length = null,
$replyToMessageId = null,
$replyMarkup = null,
$disableNotification = false
) {
return Message::fromResponse($this->call('sendVideoNote', [
'chat_id' => $... | [
"public",
"function",
"sendVideoNote",
"(",
"$",
"chatId",
",",
"$",
"videoNote",
",",
"$",
"duration",
"=",
"null",
",",
"$",
"length",
"=",
"null",
",",
"$",
"replyToMessageId",
"=",
"null",
",",
"$",
"replyMarkup",
"=",
"null",
",",
"$",
"disableNotif... | As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long.
Use this method to send video messages.
On success, the sent Message is returned.
@param int|string $chatId chat_id or @channel_name
@param \CURLFile|string $videoNote
@param int|null $duration
@param int|null $length
@param int|nu... | [
"As",
"of",
"v",
".",
"4",
".",
"0",
"Telegram",
"clients",
"support",
"rounded",
"square",
"mp4",
"videos",
"of",
"up",
"to",
"1",
"minute",
"long",
".",
"Use",
"this",
"method",
"to",
"send",
"video",
"messages",
".",
"On",
"success",
"the",
"sent",
... | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L1630-L1648 |
TelegramBot/Api | src/BotApi.php | BotApi.sendMediaGroup | public function sendMediaGroup(
$chatId,
$media,
$disableNotification = false,
$replyToMessageId = null
) {
return ArrayOfMessages::fromResponse($this->call('sendMediaGroup', [
'chat_id' => $chatId,
'media' => $media->toJson(),
'reply_to_me... | php | public function sendMediaGroup(
$chatId,
$media,
$disableNotification = false,
$replyToMessageId = null
) {
return ArrayOfMessages::fromResponse($this->call('sendMediaGroup', [
'chat_id' => $chatId,
'media' => $media->toJson(),
'reply_to_me... | [
"public",
"function",
"sendMediaGroup",
"(",
"$",
"chatId",
",",
"$",
"media",
",",
"$",
"disableNotification",
"=",
"false",
",",
"$",
"replyToMessageId",
"=",
"null",
")",
"{",
"return",
"ArrayOfMessages",
"::",
"fromResponse",
"(",
"$",
"this",
"->",
"cal... | Use this method to send a group of photos or videos as an album.
On success, the sent \TelegramBot\Api\Types\Message is returned.
@param int|string $chatId
@param ArrayOfInputMedia $media
@param int|null $replyToMessageId
@param bool $disableNotification
@return array
@throws \TelegramBot\Api\Exception | [
"Use",
"this",
"method",
"to",
"send",
"a",
"group",
"of",
"photos",
"or",
"videos",
"as",
"an",
"album",
".",
"On",
"success",
"the",
"sent",
"\\",
"TelegramBot",
"\\",
"Api",
"\\",
"Types",
"\\",
"Message",
"is",
"returned",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L1662-L1674 |
TelegramBot/Api | src/BotApi.php | BotApi.setProxy | public function setProxy($proxyString = '')
{
if (empty($proxyString)) {
$this->proxySettings = [];
return $this;
}
$this->proxySettings = [
CURLOPT_PROXY => $proxyString,
CURLOPT_HTTPPROXYTUNNEL => true,
];
return $this;
} | php | public function setProxy($proxyString = '')
{
if (empty($proxyString)) {
$this->proxySettings = [];
return $this;
}
$this->proxySettings = [
CURLOPT_PROXY => $proxyString,
CURLOPT_HTTPPROXYTUNNEL => true,
];
return $this;
} | [
"public",
"function",
"setProxy",
"(",
"$",
"proxyString",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"proxyString",
")",
")",
"{",
"$",
"this",
"->",
"proxySettings",
"=",
"[",
"]",
";",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
... | Enable proxy for curl requests. Empty string will disable proxy.
@param string $proxyString
@return BotApi | [
"Enable",
"proxy",
"for",
"curl",
"requests",
".",
"Empty",
"string",
"will",
"disable",
"proxy",
"."
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BotApi.php#L1683-L1695 |
TelegramBot/Api | src/Types/Message.php | Message.setMessageId | public function setMessageId($messageId)
{
if (is_integer($messageId) || is_float($messageId)) {
$this->messageId = $messageId;
} else {
throw new InvalidArgumentException();
}
} | php | public function setMessageId($messageId)
{
if (is_integer($messageId) || is_float($messageId)) {
$this->messageId = $messageId;
} else {
throw new InvalidArgumentException();
}
} | [
"public",
"function",
"setMessageId",
"(",
"$",
"messageId",
")",
"{",
"if",
"(",
"is_integer",
"(",
"$",
"messageId",
")",
"||",
"is_float",
"(",
"$",
"messageId",
")",
")",
"{",
"$",
"this",
"->",
"messageId",
"=",
"$",
"messageId",
";",
"}",
"else",... | @param int $messageId
@throws InvalidArgumentException | [
"@param",
"int",
"$messageId"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/Types/Message.php#L556-L563 |
TelegramBot/Api | src/BaseType.php | BaseType.validate | public static function validate($data)
{
if (count(array_intersect_key(array_flip(static::$requiredParams), $data)) === count(static::$requiredParams)) {
return true;
}
throw new InvalidArgumentException();
} | php | public static function validate($data)
{
if (count(array_intersect_key(array_flip(static::$requiredParams), $data)) === count(static::$requiredParams)) {
return true;
}
throw new InvalidArgumentException();
} | [
"public",
"static",
"function",
"validate",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"count",
"(",
"array_intersect_key",
"(",
"array_flip",
"(",
"static",
"::",
"$",
"requiredParams",
")",
",",
"$",
"data",
")",
")",
"===",
"count",
"(",
"static",
"::",
... | Validate input data
@param array $data
@return bool
@throws InvalidArgumentException | [
"Validate",
"input",
"data"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/BaseType.php#L36-L43 |
TelegramBot/Api | src/Botan.php | Botan.track | public function track(Message $message, $eventName = 'Message')
{
$uid = $message->getFrom()->getId();
$options = [
CURLOPT_URL => self::BASE_URL . "?token={$this->token}&uid={$uid}&name={$eventName}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
... | php | public function track(Message $message, $eventName = 'Message')
{
$uid = $message->getFrom()->getId();
$options = [
CURLOPT_URL => self::BASE_URL . "?token={$this->token}&uid={$uid}&name={$eventName}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
... | [
"public",
"function",
"track",
"(",
"Message",
"$",
"message",
",",
"$",
"eventName",
"=",
"'Message'",
")",
"{",
"$",
"uid",
"=",
"$",
"message",
"->",
"getFrom",
"(",
")",
"->",
"getId",
"(",
")",
";",
"$",
"options",
"=",
"[",
"CURLOPT_URL",
"=>",... | Event tracking
@param \TelegramBot\Api\Types\Message $message
@param string $eventName
@throws \TelegramBot\Api\Exception
@throws \TelegramBot\Api\HttpException | [
"Event",
"tracking"
] | train | https://github.com/TelegramBot/Api/blob/8d34f3ccd3230a9fd7c7fd9ba8ec0110a059f781/src/Botan.php#L60-L83 |
PhenX/php-font-lib | src/FontLib/Glyph/OutlineComposite.php | OutlineComposite.parseData | function parseData() {
parent::parseData();
$font = $this->getFont();
do {
$flags = $font->readUInt16();
$glyphIndex = $font->readUInt16();
$a = 1.0;
$b = 0.0;
$c = 0.0;
$d = 1.0;
$e = 0.0;
$f = 0.0;
$point_compound = null;
$point_compone... | php | function parseData() {
parent::parseData();
$font = $this->getFont();
do {
$flags = $font->readUInt16();
$glyphIndex = $font->readUInt16();
$a = 1.0;
$b = 0.0;
$c = 0.0;
$d = 1.0;
$e = 0.0;
$f = 0.0;
$point_compound = null;
$point_compone... | [
"function",
"parseData",
"(",
")",
"{",
"parent",
"::",
"parseData",
"(",
")",
";",
"$",
"font",
"=",
"$",
"this",
"->",
"getFont",
"(",
")",
";",
"do",
"{",
"$",
"flags",
"=",
"$",
"font",
"->",
"readUInt16",
"(",
")",
";",
"$",
"glyphIndex",
"=... | /*function parse() {
$this->parseData();
} | [
"/",
"*",
"function",
"parse",
"()",
"{",
"$this",
"-",
">",
"parseData",
"()",
";",
"}"
] | train | https://github.com/PhenX/php-font-lib/blob/e7c227a0d23d1db2ad2b80479b303d5a633e6b4a/src/FontLib/Glyph/OutlineComposite.php#L57-L132 |
PhenX/php-font-lib | src/FontLib/BinaryStream.php | BinaryStream.open | public function open($filename, $mode = self::modeRead) {
if (!in_array($mode, array(self::modeRead, self::modeWrite, self::modeReadWrite))) {
throw new \Exception("Unkown file open mode");
}
$this->f = fopen($filename, $mode);
return $this->f != false;
} | php | public function open($filename, $mode = self::modeRead) {
if (!in_array($mode, array(self::modeRead, self::modeWrite, self::modeReadWrite))) {
throw new \Exception("Unkown file open mode");
}
$this->f = fopen($filename, $mode);
return $this->f != false;
} | [
"public",
"function",
"open",
"(",
"$",
"filename",
",",
"$",
"mode",
"=",
"self",
"::",
"modeRead",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"mode",
",",
"array",
"(",
"self",
"::",
"modeRead",
",",
"self",
"::",
"modeWrite",
",",
"self",
"... | Open a font file in a chosen mode
@param string $filename The file name of the font to open
@param string $mode The opening mode
@throws \Exception
@return bool | [
"Open",
"a",
"font",
"file",
"in",
"a",
"chosen",
"mode"
] | train | https://github.com/PhenX/php-font-lib/blob/e7c227a0d23d1db2ad2b80479b303d5a633e6b4a/src/FontLib/BinaryStream.php#L64-L72 |
PhenX/php-font-lib | src/FontLib/BinaryStream.php | BinaryStream.getTempFile | public static function getTempFile($allow_memory = true) {
$f = null;
if ($allow_memory) {
$f = fopen("php://temp", "rb+");
}
else {
$f = fopen(tempnam(sys_get_temp_dir(), "fnt"), "rb+");
}
return $f;
} | php | public static function getTempFile($allow_memory = true) {
$f = null;
if ($allow_memory) {
$f = fopen("php://temp", "rb+");
}
else {
$f = fopen(tempnam(sys_get_temp_dir(), "fnt"), "rb+");
}
return $f;
} | [
"public",
"static",
"function",
"getTempFile",
"(",
"$",
"allow_memory",
"=",
"true",
")",
"{",
"$",
"f",
"=",
"null",
";",
"if",
"(",
"$",
"allow_memory",
")",
"{",
"$",
"f",
"=",
"fopen",
"(",
"\"php://temp\"",
",",
"\"rb+\"",
")",
";",
"}",
"else"... | Create a temporary file in write mode
@param bool $allow_memory Allow in-memory files
@return resource the temporary file pointer resource | [
"Create",
"a",
"temporary",
"file",
"in",
"write",
"mode"
] | train | https://github.com/PhenX/php-font-lib/blob/e7c227a0d23d1db2ad2b80479b303d5a633e6b4a/src/FontLib/BinaryStream.php#L103-L114 |
PhenX/php-font-lib | src/FontLib/BinaryStream.php | BinaryStream.r | public function r($type) {
switch ($type) {
case self::uint8:
return $this->readUInt8();
case self::int8:
return $this->readInt8();
case self::uint16:
return $this->readUInt16();
case self::int16:
return $this->readInt16();
case self::uint32:
ret... | php | public function r($type) {
switch ($type) {
case self::uint8:
return $this->readUInt8();
case self::int8:
return $this->readInt8();
case self::uint16:
return $this->readUInt16();
case self::int16:
return $this->readInt16();
case self::uint32:
ret... | [
"public",
"function",
"r",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"self",
"::",
"uint8",
":",
"return",
"$",
"this",
"->",
"readUInt8",
"(",
")",
";",
"case",
"self",
"::",
"int8",
":",
"return",
"$",
"this",
"-... | Read a data of type $type in the file from the current position
@param mixed $type The data type to read
@return mixed The data that was read | [
"Read",
"a",
"data",
"of",
"type",
"$type",
"in",
"the",
"file",
"from",
"the",
"current",
"position"
] | train | https://github.com/PhenX/php-font-lib/blob/e7c227a0d23d1db2ad2b80479b303d5a633e6b4a/src/FontLib/BinaryStream.php#L320-L376 |
PhenX/php-font-lib | src/FontLib/BinaryStream.php | BinaryStream.w | public function w($type, $data) {
switch ($type) {
case self::uint8:
return $this->writeUInt8($data);
case self::int8:
return $this->writeInt8($data);
case self::uint16:
return $this->writeUInt16($data);
case self::int16:
return $this->writeInt16($data);
... | php | public function w($type, $data) {
switch ($type) {
case self::uint8:
return $this->writeUInt8($data);
case self::int8:
return $this->writeInt8($data);
case self::uint16:
return $this->writeUInt16($data);
case self::int16:
return $this->writeInt16($data);
... | [
"public",
"function",
"w",
"(",
"$",
"type",
",",
"$",
"data",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"self",
"::",
"uint8",
":",
"return",
"$",
"this",
"->",
"writeUInt8",
"(",
"$",
"data",
")",
";",
"case",
"self",
"::",
"int8"... | Write $data of type $type in the file from the current position
@param mixed $type The data type to write
@param mixed $data The data to write
@return int The number of bytes read | [
"Write",
"$data",
"of",
"type",
"$type",
"in",
"the",
"file",
"from",
"the",
"current",
"position"
] | train | https://github.com/PhenX/php-font-lib/blob/e7c227a0d23d1db2ad2b80479b303d5a633e6b4a/src/FontLib/BinaryStream.php#L386-L432 |
PhenX/php-font-lib | src/FontLib/BinaryStream.php | BinaryStream.convertUInt32ToStr | public function convertUInt32ToStr($uint32) {
return chr(($uint32 >> 24) & 0xFF) . chr(($uint32 >> 16) & 0xFF) . chr(($uint32 >> 8) & 0xFF) . chr($uint32 & 0xFF);
} | php | public function convertUInt32ToStr($uint32) {
return chr(($uint32 >> 24) & 0xFF) . chr(($uint32 >> 16) & 0xFF) . chr(($uint32 >> 8) & 0xFF) . chr($uint32 & 0xFF);
} | [
"public",
"function",
"convertUInt32ToStr",
"(",
"$",
"uint32",
")",
"{",
"return",
"chr",
"(",
"(",
"$",
"uint32",
">>",
"24",
")",
"&",
"0xFF",
")",
".",
"chr",
"(",
"(",
"$",
"uint32",
">>",
"16",
")",
"&",
"0xFF",
")",
".",
"chr",
"(",
"(",
... | Converts a Uint32 value to string
@param int $uint32
@return string The string | [
"Converts",
"a",
"Uint32",
"value",
"to",
"string"
] | train | https://github.com/PhenX/php-font-lib/blob/e7c227a0d23d1db2ad2b80479b303d5a633e6b4a/src/FontLib/BinaryStream.php#L441-L443 |
PhenX/php-font-lib | src/FontLib/TrueType/File.php | File.getNameTableString | function getNameTableString($nameID) {
/** @var nameRecord[] $records */
$records = $this->getData("name", "records");
if (!isset($records[$nameID])) {
return null;
}
return $records[$nameID]->string;
} | php | function getNameTableString($nameID) {
/** @var nameRecord[] $records */
$records = $this->getData("name", "records");
if (!isset($records[$nameID])) {
return null;
}
return $records[$nameID]->string;
} | [
"function",
"getNameTableString",
"(",
"$",
"nameID",
")",
"{",
"/** @var nameRecord[] $records */",
"$",
"records",
"=",
"$",
"this",
"->",
"getData",
"(",
"\"name\"",
",",
"\"records\"",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"records",
"[",
"$",
"... | Get a specific name table string value from its ID
@param int $nameID The name ID
@return string|null | [
"Get",
"a",
"specific",
"name",
"table",
"string",
"value",
"from",
"its",
"ID"
] | train | https://github.com/PhenX/php-font-lib/blob/e7c227a0d23d1db2ad2b80479b303d5a633e6b4a/src/FontLib/TrueType/File.php#L371-L380 |
PhenX/php-font-lib | src/FontLib/EOT/File.php | File.read | public function read($n) {
if ($n < 1) {
return "";
}
$string = fread($this->f, $n);
$chunks = str_split($string, 2);
$chunks = array_map("strrev", $chunks);
return implode("", $chunks);
} | php | public function read($n) {
if ($n < 1) {
return "";
}
$string = fread($this->f, $n);
$chunks = str_split($string, 2);
$chunks = array_map("strrev", $chunks);
return implode("", $chunks);
} | [
"public",
"function",
"read",
"(",
"$",
"n",
")",
"{",
"if",
"(",
"$",
"n",
"<",
"1",
")",
"{",
"return",
"\"\"",
";",
"}",
"$",
"string",
"=",
"fread",
"(",
"$",
"this",
"->",
"f",
",",
"$",
"n",
")",
";",
"$",
"chunks",
"=",
"str_split",
... | Little endian version of the read method
@param int $n The number of bytes to read
@return string | [
"Little",
"endian",
"version",
"of",
"the",
"read",
"method"
] | train | https://github.com/PhenX/php-font-lib/blob/e7c227a0d23d1db2ad2b80479b303d5a633e6b4a/src/FontLib/EOT/File.php#L71-L81 |
PhenX/php-font-lib | src/FontLib/TrueType/Collection.php | Collection.getFont | function getFont($fontId) {
$this->parse();
if (!isset($this->collectionOffsets[$fontId])) {
throw new OutOfBoundsException();
}
if (isset($this->collection[$fontId])) {
return $this->collection[$fontId];
}
$font = new File();
$font->f = $this->f;
$font->setTableOffset(... | php | function getFont($fontId) {
$this->parse();
if (!isset($this->collectionOffsets[$fontId])) {
throw new OutOfBoundsException();
}
if (isset($this->collection[$fontId])) {
return $this->collection[$fontId];
}
$font = new File();
$font->f = $this->f;
$font->setTableOffset(... | [
"function",
"getFont",
"(",
"$",
"fontId",
")",
"{",
"$",
"this",
"->",
"parse",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"collectionOffsets",
"[",
"$",
"fontId",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",... | @param int $fontId
@throws OutOfBoundsException
@return File | [
"@param",
"int",
"$fontId"
] | train | https://github.com/PhenX/php-font-lib/blob/e7c227a0d23d1db2ad2b80479b303d5a633e6b4a/src/FontLib/TrueType/Collection.php#L55-L71 |
PhenX/php-font-lib | src/FontLib/Font.php | Font.load | public static function load($file) {
if(!file_exists($file)){
throw new FontNotFoundException($file);
}
$header = file_get_contents($file, false, null, null, 4);
$class = null;
switch ($header) {
case "\x00\x01\x00\x00":
case "true":
case "typ1":
$class = "... | php | public static function load($file) {
if(!file_exists($file)){
throw new FontNotFoundException($file);
}
$header = file_get_contents($file, false, null, null, 4);
$class = null;
switch ($header) {
case "\x00\x01\x00\x00":
case "true":
case "typ1":
$class = "... | [
"public",
"static",
"function",
"load",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"FontNotFoundException",
"(",
"$",
"file",
")",
";",
"}",
"$",
"header",
"=",
"file_get_contents",
"(",
... | @param string $file The font file
@return TrueType\File|null $file | [
"@param",
"string",
"$file",
"The",
"font",
"file"
] | train | https://github.com/PhenX/php-font-lib/blob/e7c227a0d23d1db2ad2b80479b303d5a633e6b4a/src/FontLib/Font.php#L26-L73 |
PhenX/php-font-lib | src/FontLib/Glyph/Outline.php | Outline.init | static function init(glyf $table, $offset, $size, BinaryStream $font) {
$font->seek($offset);
if ($font->readInt16() > -1) {
/** @var OutlineSimple $glyph */
$glyph = new OutlineSimple($table, $offset, $size);
}
else {
/** @var OutlineComposite $glyph */
$glyph = new OutlineComp... | php | static function init(glyf $table, $offset, $size, BinaryStream $font) {
$font->seek($offset);
if ($font->readInt16() > -1) {
/** @var OutlineSimple $glyph */
$glyph = new OutlineSimple($table, $offset, $size);
}
else {
/** @var OutlineComposite $glyph */
$glyph = new OutlineComp... | [
"static",
"function",
"init",
"(",
"glyf",
"$",
"table",
",",
"$",
"offset",
",",
"$",
"size",
",",
"BinaryStream",
"$",
"font",
")",
"{",
"$",
"font",
"->",
"seek",
"(",
"$",
"offset",
")",
";",
"if",
"(",
"$",
"font",
"->",
"readInt16",
"(",
")... | @param glyf $table
@param $offset
@param $size
@return Outline | [
"@param",
"glyf",
"$table",
"@param",
"$offset",
"@param",
"$size"
] | train | https://github.com/PhenX/php-font-lib/blob/e7c227a0d23d1db2ad2b80479b303d5a633e6b4a/src/FontLib/Glyph/Outline.php#L45-L60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.