idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
44,700
private static function getGraphqlInput ( GQL \ Input $ inputAnnotation , array $ classAnnotations , array $ properties , string $ namespace ) { $ inputConfiguration = [ ] ; $ fields = self :: getGraphqlFieldsFromAnnotations ( $ namespace , $ properties , true ) ; $ inputConfiguration [ 'fields' ] = $ fields ; $ inputC...
Create a GraphQL Input type configuration from annotations on properties .
44,701
private static function getGraphqlScalar ( string $ className , GQL \ Scalar $ scalarAnnotation , array $ classAnnotations ) { $ scalarConfiguration = [ ] ; if ( $ scalarAnnotation -> scalarType ) { $ scalarConfiguration [ 'scalarType' ] = self :: formatExpression ( $ scalarAnnotation -> scalarType ) ; } else { $ scala...
Get a Graphql scalar configuration from given scalar annotation .
44,702
private static function getGraphqlEnum ( GQL \ Enum $ enumAnnotation , array $ classAnnotations , array $ constants ) { $ enumValues = $ enumAnnotation -> values ? $ enumAnnotation -> values : [ ] ; $ values = [ ] ; foreach ( $ constants as $ name => $ value ) { $ valueAnnotation = \ current ( \ array_filter ( $ enumVa...
Get a Graphql Enum configuration from given enum annotation .
44,703
private static function getGraphqlUnion ( string $ className , GQL \ Union $ unionAnnotation , array $ classAnnotations , array $ methods ) : array { $ unionConfiguration = [ 'types' => $ unionAnnotation -> types ] ; $ unionConfiguration = self :: getDescriptionConfiguration ( $ classAnnotations ) + $ unionConfiguratio...
Get a Graphql Union configuration from given union annotation .
44,704
private static function getGraphqlFieldsFromProviders ( string $ namespace , string $ className , string $ annotationName , string $ targetType , bool $ isRoot = false ) { $ fields = [ ] ; foreach ( self :: $ providers as $ className => $ configuration ) { $ providerMethods = $ configuration [ 'methods' ] ; $ providerA...
Return fields config from Provider methods .
44,705
private static function getDescriptionConfiguration ( array $ annotations , bool $ withDeprecation = false ) { $ config = [ ] ; $ descriptionAnnotation = self :: getFirstAnnotationMatching ( $ annotations , 'Overblog\GraphQLBundle\Annotation\Description' ) ; if ( $ descriptionAnnotation ) { $ config [ 'description' ] =...
Get the config for description & deprecation reason .
44,706
private static function formatArgsForExpression ( array $ args ) { $ mapping = [ ] ; foreach ( $ args as $ name => $ config ) { $ mapping [ ] = \ sprintf ( '%s: "%s"' , $ name , $ config [ 'type' ] ) ; } return \ sprintf ( 'arguments({%s}, args)' , \ implode ( ', ' , $ mapping ) ) ; }
Format an array of args to a list of arguments in an expression .
44,707
private static function getFirstAnnotationMatching ( array $ annotations , $ annotationClass ) { if ( \ is_string ( $ annotationClass ) ) { $ annotationClass = [ $ annotationClass ] ; } foreach ( $ annotations as $ annotation ) { foreach ( $ annotationClass as $ class ) { if ( $ annotation instanceof $ class ) { return...
Get the first annotation matching given class .
44,708
private static function suffixName ( string $ name , string $ suffix ) { return \ substr ( $ name , - \ strlen ( $ suffix ) ) === $ suffix ? $ name : \ sprintf ( '%s%s' , $ name , $ suffix ) ; }
Suffix a name if it is not already .
44,709
private static function guessType ( string $ namespace , array $ annotations ) { $ columnAnnotation = self :: getFirstAnnotationMatching ( $ annotations , 'Doctrine\ORM\Mapping\Column' ) ; if ( $ columnAnnotation ) { $ type = self :: resolveTypeFromDoctrineType ( $ columnAnnotation -> type ) ; $ nullable = $ columnAnno...
Try to guess a field type base on is annotations .
44,710
private static function resolveTypeFromDoctrineType ( string $ doctrineType ) { if ( isset ( self :: $ doctrineMapping [ $ doctrineType ] ) ) { return self :: $ doctrineMapping [ $ doctrineType ] ; } switch ( $ doctrineType ) { case 'integer' : case 'smallint' : case 'bigint' : return 'Int' ; break ; case 'string' : ca...
Resolve a GraphqlType from a doctrine type .
44,711
private static function resolveGraphqlTypeFromReflectionType ( \ ReflectionType $ type , array $ filterGraphqlTypes = null , bool $ isOptionnal = false ) { $ stype = ( string ) $ type ; if ( $ type -> isBuiltin ( ) ) { $ gqlType = self :: resolveTypeFromPhpType ( $ stype ) ; if ( ! $ gqlType ) { throw new \ Exception (...
Try to guess a GraphQL type from a Reflected Type .
44,712
private static function resolveTypeFromClass ( string $ className , array $ wantedTypes = null ) { foreach ( self :: $ classesMap as $ gqlType => $ config ) { if ( $ config [ 'class' ] === $ className ) { if ( ! $ wantedTypes || \ in_array ( $ config [ 'type' ] , $ wantedTypes ) ) { return $ gqlType ; } } } return fals...
Resolve a GraphQL Type from a class name .
44,713
public function connectionFromArray ( array $ data , $ args = [ ] ) : ConnectionInterface { return $ this -> connectionFromArraySlice ( $ data , $ args , [ 'sliceStart' => 0 , 'arrayLength' => \ count ( $ data ) , ] ) ; }
A simple function that accepts an array and connection arguments and returns a connection object for use in GraphQL . It uses array offsets as pagination so pagination will only work if the array is static .
44,714
public function connectionFromPromisedArray ( $ dataPromise , $ args = [ ] ) { $ this -> checkPromise ( $ dataPromise ) ; return $ dataPromise -> then ( function ( $ data ) use ( $ args ) { return $ this -> connectionFromArray ( $ data , $ args ) ; } ) ; }
A version of connectionFromArray that takes a promised array and returns a promised connection .
44,715
public function connectionFromPromisedArraySlice ( $ dataPromise , $ args , array $ meta ) { $ this -> checkPromise ( $ dataPromise ) ; return $ dataPromise -> then ( function ( $ arraySlice ) use ( $ args , $ meta ) { return $ this -> connectionFromArraySlice ( $ arraySlice , $ args , $ meta ) ; } ) ; }
A version of connectionFromArraySlice that takes a promised array slice and returns a promised connection .
44,716
public function cursorToOffset ( $ cursor ) : string { if ( null === $ cursor ) { return '' ; } return \ str_replace ( static :: PREFIX , '' , \ base64_decode ( $ cursor , true ) ) ; }
Redefines the offset from the cursor string .
44,717
public function wait ( Promise $ promise , callable $ onProgress = null ) : ? ExecutionResult { if ( ! $ this -> isThenable ( $ promise ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The "%s" method must be call with compatible a Promise.' , __METHOD__ ) ) ; } $ wait = true ; $ resolvedValue = null ; $ excep...
Synchronously wait when promise completes .
44,718
public function toState ( ) { $ state = [ ] ; foreach ( $ this -> getErrors ( ) as $ error ) { $ state [ $ error -> getName ( ) ] = [ ] ; foreach ( $ error -> getErrors ( ) as $ violation ) { $ state [ $ error -> getName ( ) ] [ ] = [ 'path' => $ violation -> getPropertyPath ( ) , 'message' => $ violation -> getMessage...
Return a serializable array of validation errors for each argument .
44,719
private function getParsedBody ( Request $ request ) : array { $ contentType = \ explode ( ';' , ( string ) $ request -> headers -> get ( 'content-type' ) , 2 ) [ 0 ] ; switch ( $ contentType ) { case static :: CONTENT_TYPE_JSON : $ parsedBody = \ json_decode ( $ request -> getContent ( ) , true ) ; if ( \ JSON_ERROR_N...
Gets the body from the request .
44,720
private function getTypeClassInstance ( string $ type ) { $ classname = isset ( $ this -> classesMap [ $ type ] ) ? $ this -> classesMap [ $ type ] [ 'class' ] : false ; return $ classname ? new $ classname ( ) : false ; }
Get the PHP class for a given type .
44,721
private function getType ( string $ type , ResolveInfo $ info ) : Type { return $ info -> schema -> getType ( $ type ) ; }
Extract given type from Resolve Info .
44,722
private function populateObject ( Type $ type , $ data , $ multiple = false , ResolveInfo $ info ) { if ( ! $ data ) { return $ data ; } if ( $ multiple ) { return \ array_map ( function ( $ data ) use ( $ type , $ info ) { return $ this -> populateObject ( $ type , $ data , false , $ info ) ; } , $ data ) ; } if ( $ t...
Populate an object based on type with given data .
44,723
public function getInstanceAndValidate ( string $ argType , $ data , ResolveInfo $ info , string $ argName ) { $ isRequired = '!' === $ argType [ \ strlen ( $ argType ) - 1 ] ; $ isMultiple = '[' === $ argType [ 0 ] ; $ endIndex = ( $ isRequired ? 1 : 0 ) + ( $ isMultiple ? 1 : 0 ) ; $ type = \ substr ( $ argType , $ i...
Given a GraphQL type and an array of data populate corresponding object recursively using annoted classes .
44,724
public function getArguments ( array $ mapping , $ data , ResolveInfo $ info ) { $ args = [ ] ; $ exceptions = [ ] ; foreach ( $ mapping as $ name => $ type ) { try { $ value = $ this -> getInstanceAndValidate ( $ type , $ data [ $ name ] , $ info , $ name ) ; $ args [ ] = $ value ; } catch ( InvalidArgumentError $ exc...
Transform a list of arguments into their corresponding php class and validate them .
44,725
protected function validateItems ( & $ value , $ schema = null , JsonPointer $ path = null , $ i = null ) { if ( is_object ( $ schema -> items ) ) { foreach ( $ value as $ k => & $ v ) { $ initErrors = $ this -> getErrors ( ) ; $ this -> checkUndefined ( $ v , $ schema -> items , $ path , $ k ) ; if ( count ( $ initErr...
Validates the items
44,726
private function expandRefs ( & $ schema , $ base = null ) { if ( ! is_object ( $ schema ) ) { if ( is_array ( $ schema ) ) { foreach ( $ schema as & $ member ) { $ this -> expandRefs ( $ member , $ base ) ; } } return ; } if ( property_exists ( $ schema , 'id' ) && is_string ( $ schema -> id ) && $ base != $ schema ->...
Recursively resolve all references against the provided base
44,727
public function getConfig ( $ options = null ) { if ( $ options === null ) { return $ this -> checkMode ; } return $ this -> checkMode & $ options ; }
Get checkMode option
44,728
public function createInstanceFor ( $ constraintName ) { if ( ! isset ( $ this -> constraintMap [ $ constraintName ] ) ) { throw new InvalidArgumentException ( 'Unknown constraint ' . $ constraintName ) ; } if ( ! isset ( $ this -> instanceCache [ $ constraintName ] ) ) { $ this -> instanceCache [ $ constraintName ] = ...
Create a constraint instance for the given constraint name .
44,729
protected function incrementPath ( JsonPointer $ path = null , $ i ) { $ path = $ path ? : new JsonPointer ( '' ) ; $ path = $ path -> withPropertyPaths ( array_merge ( $ path -> getPropertyPaths ( ) , array_filter ( array ( $ i ) , 'strlen' ) ) ) ; return $ path ; }
Bubble down the path
44,730
protected function checkArray ( & $ value , $ schema = null , JsonPointer $ path = null , $ i = null ) { $ validator = $ this -> factory -> createInstanceFor ( 'collection' ) ; $ validator -> check ( $ value , $ schema , $ path , $ i ) ; $ this -> addErrors ( $ validator -> getErrors ( ) ) ; }
Validates an array
44,731
protected function checkObject ( & $ value , $ schema = null , JsonPointer $ path = null , $ properties = null , $ additionalProperties = null , $ patternProperties = null , $ appliedDefaults = array ( ) ) { $ validator = $ this -> factory -> createInstanceFor ( 'object' ) ; $ validator -> check ( $ value , $ schema , ...
Validates an object
44,732
protected function checkUndefined ( & $ value , $ schema = null , JsonPointer $ path = null , $ i = null , $ fromDefault = false ) { $ validator = $ this -> factory -> createInstanceFor ( 'undefined' ) ; $ validator -> check ( $ value , $ this -> factory -> getSchemaStorage ( ) -> resolveRefSchema ( $ schema ) , $ path...
Checks a undefined element
44,733
protected function validateType ( & $ value , $ type , $ coerce = false ) { if ( ! $ type ) { return true ; } if ( 'any' === $ type ) { return true ; } if ( 'object' === $ type ) { return $ this -> getTypeCheck ( ) -> isObject ( $ value ) ; } if ( 'array' === $ type ) { if ( $ coerce ) { $ value = $ this -> toArray ( $...
Verifies that a given value is of a certain type
44,734
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 ) { return $ this -> toBoolean ( reset ( $ value...
Converts a value to boolean . For example true becomes true .
44,735
protected function toNumber ( $ value ) { if ( is_numeric ( $ value ) ) { return $ value + 0 ; } if ( is_bool ( $ value ) || is_null ( $ value ) ) { return ( int ) $ value ; } if ( $ this -> getTypeCheck ( ) -> isArray ( $ value ) && count ( $ value ) === 1 ) { return $ this -> toNumber ( reset ( $ value ) ) ; } return...
Converts a value to a number . For example 4 . 5 becomes 4 . 5 .
44,736
protected function toInteger ( $ value ) { $ numberValue = $ this -> toNumber ( $ value ) ; if ( is_numeric ( $ numberValue ) && ( int ) $ numberValue == $ numberValue ) { return ( int ) $ numberValue ; } return $ value ; }
Converts a value to an integer . For example 4 becomes 4 .
44,737
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 '' ; } if ( $ this -> getTypeCheck ( ) -> isArray ( $ value ) && count ( $ value ) === 1 ) { return ...
Convert a value to a string representation of that value . For example null becomes .
44,738
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 ; }
Convert a value to a null . For example 0 becomes null .
44,739
public function parse ( $ uri ) { preg_match ( '|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|' , $ uri , $ match ) ; $ components = array ( ) ; if ( 5 < count ( $ match ) ) { $ components = array ( 'scheme' => $ match [ 2 ] , 'authority' => $ match [ 4 ] , 'path' => $ match [ 5 ] ) ; } if ( 7 < count ( $ ...
Parses a URI into five main components
44,740
public function generate ( array $ components ) { $ uri = $ components [ 'scheme' ] . '://' . $ components [ 'authority' ] . $ components [ 'path' ] ; if ( array_key_exists ( 'query' , $ components ) && strlen ( $ components [ 'query' ] ) ) { $ uri .= '?' . $ components [ 'query' ] ; } if ( array_key_exists ( 'fragment...
Builds a URI based on n array with the main components
44,741
public static function combineRelativePathWithBasePath ( $ relativePath , $ basePath ) { $ relativePath = self :: normalizePath ( $ relativePath ) ; if ( $ relativePath == '' ) { return $ basePath ; } if ( $ relativePath [ 0 ] == '/' ) { return $ relativePath ; } $ basePathSegments = explode ( '/' , $ basePath ) ; preg...
Tries to glue a relative path onto an absolute one
44,742
public function confirmMediaType ( $ uriRetriever , $ uri ) { $ contentType = $ uriRetriever -> getContentType ( ) ; if ( is_null ( $ contentType ) ) { return ; } if ( in_array ( $ contentType , array ( Validator :: SCHEMA_MEDIA_TYPE , 'application/json' ) ) ) { return ; } foreach ( $ this -> allowedInvalidContentTypeE...
Guarantee the correct media type was encountered
44,743
public function resolvePointer ( $ jsonSchema , $ uri ) { $ resolver = new UriResolver ( ) ; $ parsed = $ resolver -> parse ( $ uri ) ; if ( empty ( $ parsed [ 'fragment' ] ) ) { return $ jsonSchema ; } $ path = explode ( '/' , $ parsed [ 'fragment' ] ) ; while ( $ path ) { $ pathElement = array_shift ( $ path ) ; if (...
Resolve a schema based on pointer
44,744
protected function loadSchema ( $ fetchUri ) { if ( isset ( $ this -> schemaCache [ $ fetchUri ] ) ) { return $ this -> schemaCache [ $ fetchUri ] ; } $ uriRetriever = $ this -> getUriRetriever ( ) ; $ contents = $ this -> uriRetriever -> retrieve ( $ fetchUri ) ; $ this -> confirmMediaType ( $ uriRetriever , $ fetchUr...
Fetch a schema from the given URI json - decode it and return it . Caches schema objects .
44,745
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 ) ; $ basePath = $ ba...
Resolves a URI
44,746
public function translate ( $ uri ) { foreach ( $ this -> translationMap as $ from => $ to ) { $ uri = preg_replace ( $ from , $ to , $ uri ) ; } $ uri = preg_replace ( '|^package://|' , sprintf ( 'file://%s/' , realpath ( __DIR__ . '/../../..' ) ) , $ uri ) ; return $ uri ; }
Apply URI translation rules
44,747
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 ( $ properties ,...
Validates the element properties
44,748
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 ) ; $ defini...
Validates the definition properties
44,749
protected function & getProperty ( & $ element , $ property , $ fallback = null ) { if ( is_array ( $ element ) && ( isset ( $ element [ $ property ] ) || array_key_exists ( $ property , $ element ) ) ) { return $ element [ $ property ] ; } elseif ( is_object ( $ element ) && property_exists ( $ element , $ property ) ...
retrieves a property from an object or array
44,750
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 ] : '+00:00...
Try creating a DateTime instance
44,751
public function validateTypes ( & $ value , $ schema = null , JsonPointer $ path , $ i = null ) { if ( $ this -> getTypeCheck ( ) -> isArray ( $ value ) ) { $ this -> checkArray ( $ value , $ schema , $ path , $ i ) ; } if ( LooseTypeCheck :: isObject ( $ value ) ) { $ this -> checkObject ( $ value , $ schema , $ path ...
Validates the value against the types
44,752
private function shouldApplyDefaultValue ( $ requiredOnly , $ schema , $ name = null , $ parentSchema = null ) { if ( ! $ requiredOnly ) { return true ; } if ( $ name !== null && isset ( $ parentSchema -> required ) && is_array ( $ parentSchema -> required ) && in_array ( $ name , $ parentSchema -> required ) ) { retur...
Check whether a default should be applied for this value
44,753
protected function applyDefaultValues ( & $ value , $ schema , $ path ) { if ( ! $ this -> factory -> getConfig ( self :: CHECK_MODE_APPLY_DEFAULTS ) ) { return ; } $ requiredOnly = $ this -> factory -> getConfig ( self :: CHECK_MODE_ONLY_REQUIRED_DEFAULTS ) ; if ( isset ( $ schema -> properties ) && LooseTypeCheck :: ...
Apply default values
44,754
protected function validateOfProperties ( & $ value , $ schema , JsonPointer $ path , $ i = '' ) { if ( $ value instanceof self ) { return ; } if ( isset ( $ schema -> allOf ) ) { $ isValid = true ; foreach ( $ schema -> allOf as $ allOf ) { $ initErrors = $ this -> getErrors ( ) ; $ this -> checkUndefined ( $ value , ...
Validate allOf anyOf and oneOf properties
44,755
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_error_msg ( ) ; } throw new InvalidArgu...
Recursively cast an associative array to an object
44,756
public function add ( Closure $ event , $ checker = null ) { $ this -> events [ ] = ! is_null ( $ checker ) ? new Event ( $ event , $ checker ) : new Event ( $ event , function ( ) { } ) ; return $ this ; }
Add new event to collection
44,757
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 .
44,758
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 ( isset ( $ matches [ 3 ] ) && ! empty ( $ matches [ 3 ...
Returns event function to handling the command .
44,759
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 ( ) , $ matches ) ; return ! empty (...
Returns check function to handling the command .
44,760
public function sendMessage ( $ chatId , $ text , $ parseMode = null , $ disablePreview = false , $ replyToMessageId = null , $ replyMarkup = null , $ disableNotification = false ) { return Message :: fromResponse ( $ this -> call ( 'sendMessage' , [ 'chat_id' => $ chatId , 'text' => $ text , 'parse_mode' => $ parseMod...
Use this method to send text messages . On success the sent \ TelegramBot \ Api \ Types \ Message is returned .
44,761
public function sendContact ( $ chatId , $ phoneNumber , $ firstName , $ lastName = null , $ replyToMessageId = null , $ replyMarkup = null , $ disableNotification = false ) { return Message :: fromResponse ( $ this -> call ( 'sendContact' , [ 'chat_id' => $ chatId , 'phone_number' => $ phoneNumber , 'first_name' => $ ...
Use this method to send phone contacts
44,762
public function getUserProfilePhotos ( $ userId , $ offset = 0 , $ limit = 100 ) { return UserProfilePhotos :: fromResponse ( $ this -> call ( 'getUserProfilePhotos' , [ 'user_id' => ( int ) $ userId , 'offset' => ( int ) $ offset , 'limit' => ( int ) $ limit , ] ) ) ; }
Use this method to get a list of profile pictures for a user .
44,763
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 ) { foreach ( $ updates as $ update ) { $ this...
Use this method to receive incoming updates using long polling . An Array of Update objects is returned .
44,764
public function sendLocation ( $ chatId , $ latitude , $ longitude , $ replyToMessageId = null , $ replyMarkup = null , $ disableNotification = false , $ livePeriod = null ) { return Message :: fromResponse ( $ this -> call ( 'sendLocation' , [ 'chat_id' => $ chatId , 'latitude' => $ latitude , 'longitude' => $ longitu...
Use this method to send point on the map . On success the sent Message is returned .
44,765
public function sendVenue ( $ chatId , $ latitude , $ longitude , $ title , $ address , $ foursquareId = null , $ replyToMessageId = null , $ replyMarkup = null , $ disableNotification = false ) { return Message :: fromResponse ( $ this -> call ( 'sendVenue' , [ 'chat_id' => $ chatId , 'latitude' => $ latitude , 'longi...
Use this method to send information about a venue . On success the sent Message is returned .
44,766
public function sendSticker ( $ chatId , $ sticker , $ replyToMessageId = null , $ replyMarkup = null , $ disableNotification = false ) { return Message :: fromResponse ( $ this -> call ( 'sendSticker' , [ 'chat_id' => $ chatId , 'sticker' => $ sticker , 'reply_to_message_id' => $ replyToMessageId , 'reply_markup' => i...
Use this method to send . webp stickers . On success the sent Message is returned .
44,767
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_notification' => ( bool ) $ disableNot...
Use this method to forward messages of any kind . On success the sent Message is returned .
44,768
public function sendAudio ( $ chatId , $ audio , $ duration = null , $ performer = null , $ title = null , $ replyToMessageId = null , $ replyMarkup = null , $ disableNotification = false , $ parseMode = null ) { return Message :: fromResponse ( $ this -> call ( 'sendAudio' , [ 'chat_id' => $ chatId , 'audio' => $ audi...
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 .
44,769
public function sendPhoto ( $ chatId , $ photo , $ caption = null , $ replyToMessageId = null , $ replyMarkup = null , $ disableNotification = false , $ parseMode = null ) { return Message :: fromResponse ( $ this -> call ( 'sendPhoto' , [ 'chat_id' => $ chatId , 'photo' => $ photo , 'caption' => $ caption , 'reply_to_...
Use this method to send photos . On success the sent Message is returned .
44,770
public function sendDocument ( $ chatId , $ document , $ caption = null , $ replyToMessageId = null , $ replyMarkup = null , $ disableNotification = false , $ parseMode = null ) { return Message :: fromResponse ( $ this -> call ( 'sendDocument' , [ 'chat_id' => $ chatId , 'document' => $ document , 'caption' => $ capti...
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 .
44,771
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 -> executeCurl ( $ options ) ; }
Get file contents via cURL
44,772
public function answerInlineQuery ( $ inlineQueryId , $ results , $ cacheTime = 300 , $ isPersonal = false , $ nextOffset = '' , $ switchPmText = null , $ switchPmParameter = null ) { $ results = array_map ( function ( $ item ) { return json_decode ( $ item -> toJson ( ) , true ) ; } , $ results ) ; return $ this -> ca...
Use this method to send answers to an inline query . On success True is returned . No more than 50 results per query are allowed .
44,773
public function kickChatMember ( $ chatId , $ userId , $ untilDate = null ) { return $ this -> call ( 'kickChatMember' , [ 'chat_id' => $ chatId , 'user_id' => $ userId , 'until_date' => $ untilDate ] ) ; }
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 .
44,774
public function answerCallbackQuery ( $ callbackQueryId , $ text = null , $ showAlert = false ) { return $ this -> call ( 'answerCallbackQuery' , [ 'callback_query_id' => $ callbackQueryId , 'text' => $ text , 'show_alert' => ( bool ) $ showAlert , ] ) ; }
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 .
44,775
public function track ( Message $ message , $ eventName = 'Message' ) { if ( $ this -> tracker instanceof Botan ) { $ this -> tracker -> track ( $ message , $ eventName ) ; } }
Wrapper for tracker
44,776
public function sendInvoice ( $ chatId , $ title , $ description , $ payload , $ providerToken , $ startParameter , $ currency , $ prices , $ isFlexible = false , $ photoUrl = null , $ photoSize = null , $ photoWidth = null , $ photoHeight = null , $ needName = false , $ needPhoneNumber = false , $ needEmail = false , ...
Use this method to send invoices . On success the sent Message is returned .
44,777
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 ) , 'error_message' => ...
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 .
44,778
public function restrictChatMember ( $ chatId , $ userId , $ untilDate = null , $ canSendMessages = false , $ canSendMediaMessages = false , $ canSendOtherMessages = false , $ canAddWebPagePreviews = false ) { return $ this -> call ( 'restrictChatMember' , [ 'chat_id' => $ chatId , 'user_id' => $ userId , 'until_date' ...
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 .
44,779
public function promoteChatMember ( $ chatId , $ userId , $ canChangeInfo = true , $ canPostMessages = true , $ canEditMessages = true , $ canDeleteMessages = true , $ canInviteUsers = true , $ canRestrictMembers = true , $ canPinMessages = true , $ canPromoteMembers = true ) { return $ this -> call ( 'promoteChatMembe...
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 .
44,780
public function pinChatMessage ( $ chatId , $ messageId , $ disableNotification = false ) { return $ this -> call ( 'pinChatMessage' , [ 'chat_id' => $ chatId , 'message_id' => $ messageId , 'disable_notification' => $ disableNotification ] ) ; }
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 .
44,781
public function sendVideoNote ( $ chatId , $ videoNote , $ duration = null , $ length = null , $ replyToMessageId = null , $ replyMarkup = null , $ disableNotification = false ) { return Message :: fromResponse ( $ this -> call ( 'sendVideoNote' , [ 'chat_id' => $ chatId , 'video_note' => $ videoNote , 'duration' => $ ...
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 .
44,782
public function sendMediaGroup ( $ chatId , $ media , $ disableNotification = false , $ replyToMessageId = null ) { return ArrayOfMessages :: fromResponse ( $ this -> call ( 'sendMediaGroup' , [ 'chat_id' => $ chatId , 'media' => $ media -> toJson ( ) , 'reply_to_message_id' => ( int ) $ replyToMessageId , 'disable_not...
Use this method to send a group of photos or videos as an album . On success the sent \ TelegramBot \ Api \ Types \ Message is returned .
44,783
public function setProxy ( $ proxyString = '' ) { if ( empty ( $ proxyString ) ) { $ this -> proxySettings = [ ] ; return $ this ; } $ this -> proxySettings = [ CURLOPT_PROXY => $ proxyString , CURLOPT_HTTPPROXYTUNNEL => true , ] ; return $ this ; }
Enable proxy for curl requests . Empty string will disable proxy .
44,784
public static function validate ( $ data ) { if ( count ( array_intersect_key ( array_flip ( static :: $ requiredParams ) , $ data ) ) === count ( static :: $ requiredParams ) ) { return true ; } throw new InvalidArgumentException ( ) ; }
Validate input data
44,785
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 ; }
Open a font file in a chosen mode
44,786
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 ; }
Create a temporary file in write mode
44,787
public function convertUInt32ToStr ( $ uint32 ) { return chr ( ( $ uint32 >> 24 ) & 0xFF ) . chr ( ( $ uint32 >> 16 ) & 0xFF ) . chr ( ( $ uint32 >> 8 ) & 0xFF ) . chr ( $ uint32 & 0xFF ) ; }
Converts a Uint32 value to string
44,788
function getNameTableString ( $ nameID ) { $ records = $ this -> getData ( "name" , "records" ) ; if ( ! isset ( $ records [ $ nameID ] ) ) { return null ; } return $ records [ $ nameID ] -> string ; }
Get a specific name table string value from its ID
44,789
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 ) ; }
Little endian version of the read method
44,790
public function refreshSession ( ) { $ this -> objCurl = curl_init ( ) ; $ this -> arrCurlOptions [ CURLOPT_COOKIEJAR ] = $ this -> strCookieFile ; $ this -> arrCurlOptions [ CURLOPT_COOKIEFILE ] = $ this -> strCookieFile ; curl_setopt_array ( $ this -> objCurl , $ this -> arrCurlOptions ) ; }
Create a new curl instance
44,791
private function checkCookieAuth ( ) { if ( strlen ( trim ( $ this -> getUsername ( ) ) ) == 0 ) { $ this -> objConnector -> cleanupSession ( ) ; $ this -> objConnector -> refreshSession ( ) ; return false ; } return true ; }
Try to read the username from the API - if successful it means we have a valid cookie and we don t need to auth
44,792
public function getActivityList ( $ intStart = 0 , $ intLimit = 10 , $ strActivityType = null ) { $ arrParams = array ( 'start' => $ intStart , 'limit' => $ intLimit ) ; if ( null !== $ strActivityType ) { $ arrParams [ 'activityType' ] = $ strActivityType ; } $ strResponse = $ this -> objConnector -> get ( 'https://co...
Gets a list of activities
44,793
public function getActivityDetails ( $ intActivityID ) { $ strResponse = $ this -> objConnector -> get ( "https://connect.garmin.com/proxy/activity-service/details/" . $ intActivityID ) ; if ( $ this -> objConnector -> getLastResponseCode ( ) != 200 ) { throw new UnexpectedResponseCodeException ( $ this -> objConnector...
Gets the detailed information for the activity
44,794
public function getDataFile ( $ strType , $ intActivityID ) { switch ( $ strType ) { case self :: DATA_TYPE_GPX : case self :: DATA_TYPE_TCX : case self :: DATA_TYPE_GOOGLE_EARTH : break ; default : throw new Exception ( "Unsupported data type" ) ; } $ strUrl = "https://connect.garmin.com/modern/proxy/download-service/...
Retrieves the data file for the activity
44,795
public function getWeightData ( $ strFrom = '2019-01-01' , $ strUntil = '2099-12-31' ) { $ intDateFrom = ( strtotime ( $ strFrom ) + 86400 ) * 1000 ; $ intDateUntil = strtotime ( $ strUntil ) * 1000 ; $ arrParams = array ( 'from' => $ intDateFrom , 'until' => $ intDateUntil ) ; $ strResponse = $ this -> objConnector ->...
Retrieves weight data
44,796
protected function readObject ( $ path ) { $ object = $ this -> applyPathPrefix ( $ path ) ; $ result [ 'Body' ] = $ this -> client -> getObject ( $ this -> bucket , $ object ) ; $ result = array_merge ( $ result , [ 'type' => 'file' ] ) ; return $ this -> normalizeResponse ( $ result , $ path ) ; }
Read an object from the OssClient .
44,797
protected function getObjectACL ( $ path ) { $ metadata = $ this -> getVisibility ( $ path ) ; return $ metadata [ 'visibility' ] === AdapterInterface :: VISIBILITY_PUBLIC ? OssClient :: OSS_ACL_TYPE_PUBLIC_READ : OssClient :: OSS_ACL_TYPE_PRIVATE ; }
The the ACL visibility .
44,798
protected function normalizeResponse ( array $ object , $ path = null ) { $ result = [ 'path' => $ path ? : $ this -> removePathPrefix ( isset ( $ object [ 'Key' ] ) ? $ object [ 'Key' ] : $ object [ 'Prefix' ] ) ] ; $ result [ 'dirname' ] = Util :: dirname ( $ result [ 'path' ] ) ; if ( isset ( $ object [ 'LastModifie...
Normalize a result from OSS .
44,799
protected function getOptions ( array $ options = [ ] , Config $ config = null ) { $ options = array_merge ( $ this -> options , $ options ) ; if ( $ config ) { $ options = array_merge ( $ options , $ this -> getOptionsFromConfig ( $ config ) ) ; } return array ( OssClient :: OSS_HEADERS => $ options ) ; }
Get options for a OSS call . done