idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
50,600
public function notify ( $ interests , array $ data , $ debug = false ) { $ postData = [ ] ; if ( is_string ( $ interests ) ) { $ interests = [ $ interests ] ; } if ( count ( $ interests ) == 0 ) { throw new ExpoException ( 'Interests array must not be empty.' ) ; } $ recipients = $ this -> registrar -> getInterests ( ...
Send a notification via the Expo Push Notifications Api .
50,601
private function failedCompletely ( array $ response , array $ interests ) { $ numberOfInterests = count ( $ interests ) ; $ numberOfFailures = 0 ; foreach ( $ response as $ item ) { if ( $ item [ 'status' ] === 'error' ) { $ numberOfFailures ++ ; } } return $ numberOfFailures === $ numberOfInterests ; }
Determines if the request we sent has failed completely
50,602
private function prepareCurl ( ) { $ ch = $ this -> getCurl ( ) ; curl_setopt ( $ ch , CURLOPT_URL , self :: EXPO_API_URL ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , [ 'accept: application/json' , 'content-type: application/json' , ] ) ; curl_setopt ( $ ch , CURLOPT_POST , 1 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRA...
Sets the request url and headers
50,603
public function getCurl ( ) { $ this -> ch = $ this -> ch ?? curl_init ( ) ; if ( ! $ this -> ch ) { throw new ExpoException ( 'Could not initialise cURL!' ) ; } return $ this -> ch ; }
Get the cURL resource
50,604
private function executeCurl ( $ ch ) { $ response = [ 'body' => curl_exec ( $ ch ) , 'status_code' => curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ] ; return json_decode ( $ response [ 'body' ] , true ) [ 'data' ] ; }
Executes cURL and captures the response
50,605
public static function failedCompletelyException ( $ response ) { $ message = '' ; foreach ( $ response as $ key => $ item ) { if ( $ item [ 'status' ] === 'error' ) { $ message .= $ key == 0 ? "" : "\r\n" ; $ message .= $ item [ 'message' ] ; } } return new static ( $ message ) ; }
Formats the exception for a completely failed request
50,606
public function store ( $ key , $ value ) : bool { $ storageInstance = null ; try { $ storageInstance = $ this -> getRepository ( ) ; } catch ( \ Exception $ e ) { $ storageInstance = $ this -> createFile ( ) ; } if ( isset ( $ storageInstance -> { $ key } ) ) { if ( ! is_array ( $ storageInstance -> { $ key } ) ) { $ ...
Stores an Expo token with a given identifier
50,607
public function retrieve ( string $ key ) { $ token = null ; $ storageInstance = $ this -> getRepository ( ) ; $ token = $ storageInstance -> { $ key } ?? null ; return $ token ; }
Retrieves an Expo token with a given identifier
50,608
public function forget ( string $ key , string $ value = null ) : bool { $ storageInstance = null ; try { $ storageInstance = $ this -> getRepository ( ) ; } catch ( \ Exception $ e ) { return false ; } if ( $ value && isset ( $ storageInstance -> { $ key } ) && is_array ( $ storageInstance -> { $ key } ) && count ( $ ...
Removes an Expo token with a given identifier
50,609
private function getRepository ( ) { if ( ! file_exists ( $ this -> storage ) ) { throw new \ Exception ( 'Tokens storage file not found.' ) ; } $ file = file_get_contents ( $ this -> storage ) ; return json_decode ( $ file ) ; }
Gets the storage file contents and converts it into an object
50,610
private function createFile ( ) { $ file = fopen ( $ this -> storage , "w" ) ; fputs ( $ file , '{}' ) ; fclose ( $ file ) ; return json_decode ( '{}' ) ; }
Creates the storage file
50,611
public function registerInterest ( $ interest , $ token ) { if ( ! $ this -> isValidExpoPushToken ( $ token ) ) { throw ExpoRegistrarException :: invalidToken ( ) ; } $ stored = $ this -> repository -> store ( $ interest , $ token ) ; if ( ! $ stored ) { throw ExpoRegistrarException :: couldNotRegisterInterest ( ) ; } ...
Registers the given token for the given interest
50,612
public function removeInterest ( $ interest , $ token = null ) { if ( ! $ this -> repository -> forget ( $ interest , $ token ) ) { throw ExpoRegistrarException :: couldNotRemoveInterest ( ) ; } return true ; }
Removes token of a given interest
50,613
public function getInterests ( array $ interests ) : array { $ tokens = [ ] ; foreach ( $ interests as $ interest ) { $ retrieved = $ this -> repository -> retrieve ( $ interest ) ; if ( ! is_null ( $ retrieved ) ) { if ( is_string ( $ retrieved ) ) { $ tokens [ ] = $ retrieved ; } if ( is_array ( $ retrieved ) ) { for...
Gets the tokens of the interests
50,614
public function send ( Message $ message ) { return $ this -> guzzleClient -> post ( $ this -> getApiUrl ( ) , [ 'headers' => [ 'Authorization' => sprintf ( 'key=%s' , $ this -> apiKey ) , 'Content-Type' => 'application/json' ] , 'body' => json_encode ( $ message ) ] ) ; }
sends your notification to the google servers and returns a guzzle repsonse object containing their answer .
50,615
private function _nominatim ( array $ parts ) { $ keys = [ 'house_number' , 'address29' , 'type' , 'pedestrian' , 'footway' , 'path' , 'road' , 'neighbourhood' , 'suburb' , 'village' , 'town' , 'city_district' , 'city' , 'postcode' , 'county' , 'state_district' , 'state' , 'country' , ] ; foreach ( $ keys as $ key ) if...
Parse Nominatim parts
50,616
private function _mapbox ( array $ parts ) { $ parts = array_reduce ( $ parts , function ( $ a , $ part ) { $ key = explode ( '.' , $ part [ 'id' ] ) [ 0 ] ; $ a [ $ key ] = $ part [ 'text' ] ; return $ a ; } , [ 'number' => $ parts [ 'address' ] , $ parts [ 'place_type' ] [ 0 ] => $ parts [ 'text' ] , ] ) ; $ this -> ...
Parse Mapbox parts
50,617
private function _google ( $ parts ) { if ( ! $ this -> _isAssoc ( $ parts ) ) { $ parts = array_reduce ( $ parts , function ( $ a , $ part ) { $ key = $ part [ 'types' ] [ 0 ] ; $ a [ $ key ] = $ part [ 'long_name' ] ; return $ a ; } , [ ] ) ; } foreach ( PartsLegacy :: $ legacyKeys as $ key ) if ( ! array_key_exists ...
Parse Google parts
50,618
private function _here ( $ parts ) { $ parts = array_merge ( $ parts , array_reduce ( $ parts [ 'additionalData' ] , function ( $ a , $ b ) { $ a [ $ b [ 'key' ] ] = $ b [ 'value' ] ; return $ a ; } , [ ] ) ) ; $ this -> number = $ parts [ 'number' ] ; $ this -> address = $ this -> _join ( [ $ parts [ 'street' ] , $ pa...
Parse Here parts
50,619
public static function isLegacy ( array $ parts = null ) { if ( $ parts === null ) return false ; $ keys = PartsLegacy :: $ legacyKeys ; unset ( $ keys [ array_search ( 'country' , $ keys ) ] ) ; foreach ( $ keys as $ key ) if ( isset ( $ parts [ $ key ] ) || array_key_exists ( $ key , $ parts ) ) return true ; return ...
Determines if the given array of parts contains legacy data
50,620
private function _fromArray ( array $ parts ) { $ this -> number = $ parts [ 'number' ] ?? '' ; $ this -> address = $ parts [ 'address' ] ?? '' ; $ this -> city = $ parts [ 'city' ] ?? '' ; $ this -> postcode = $ parts [ 'postcode' ] ?? '' ; $ this -> county = $ parts [ 'county' ] ?? '' ; $ this -> state = $ parts [ 's...
Populates Parts from the given array
50,621
public static function getToken ( $ token , string $ service ) { switch ( $ service ) { case GeoEnum :: AppleMapKit : case MapTiles :: MapKitStandard : case MapTiles :: MapKitMutedStandard : case MapTiles :: MapKitSatellite : case MapTiles :: MapKitHybrid : return JWT :: getToken ( trim ( $ token [ 'privateKey' ] ) , t...
Parses the token based off the given service
50,622
public function getMapToken ( ) { $ settings = SimpleMap :: getInstance ( ) -> getSettings ( ) ; return GeoService :: getToken ( $ settings -> mapToken , $ settings -> mapTiles ) ; }
Returns the map token
50,623
private function _searchLocation ( ElementQuery $ query , $ value , $ table ) { $ location = $ value [ 'location' ] ; $ country = $ value [ 'country' ] ?? null ; $ radius = $ value [ 'radius' ] ?? 50.0 ; $ unit = $ value [ 'unit' ] ?? 'km' ; if ( is_string ( $ location ) ) $ location = GeoService :: latLngFromAddress (...
Filters the query by location .
50,624
private function _replaceOrderBy ( ElementQuery $ query , $ search = false ) { $ nextOrder = [ ] ; foreach ( ( array ) $ query -> orderBy as $ order => $ sort ) { if ( $ order === 'distance' && $ search ) $ nextOrder [ $ search ] = $ sort ; elseif ( $ order !== 'distance' ) $ nextOrder [ $ order ] = $ sort ; } $ query ...
Will replace the distance search with the correct query if available or otherwise remove it .
50,625
private function _populateMissingData ( MapRecord $ record ) { if ( ! ( $ record -> lat && $ record -> lng ) && $ record -> address ) { $ latLng = GeoService :: latLngFromAddress ( $ record -> address ) ; $ record -> lat = $ latLng [ 'lat' ] ; $ record -> lng = $ latLng [ 'lng' ] ; } if ( ! $ record -> address && ( $ r...
Populates any missing location data
50,626
private function _upgrade2 ( ) { $ craft = \ Craft :: $ app ; $ elements = $ craft -> elements ; $ this -> delete ( Table :: PLUGINS , [ 'handle' => 'simple-map' ] ) ; echo ' > Start map data upgrade' . PHP_EOL ; $ rows = ( new Query ( ) ) -> select ( '*' ) -> from ( '{{%simplemap_maps}}' ) -> all ( ) ; foreach ( $ ...
Upgrade from Craft 2
50,627
private function locale2handle ( string $ locale ) : string { if ( ! preg_match ( '/^' . HandleValidator :: $ handlePattern . '$/' , $ locale ) || in_array ( strtolower ( $ locale ) , HandleValidator :: $ baseReservedWords , true ) ) { $ localeParts = array_filter ( preg_split ( '/[^a-zA-Z0-9]/' , $ locale ) ) ; return...
Returns a site handle based on a given locale .
50,628
private function getSiteByLocale ( $ locale ) { $ sites = \ Craft :: $ app -> sites ; if ( $ locale === null ) return static :: $ sitesByOldLocale [ $ locale ] = $ sites -> primarySite ; if ( array_key_exists ( $ locale , static :: $ sitesByOldLocale ) ) return static :: $ sitesByOldLocale [ $ locale ] ; $ handle = $ t...
Gets the new site based off the old locale
50,629
private function updatePluginSettings ( ) { echo ' > Upgrade Maps settings' . PHP_EOL ; $ settings = SimpleMap :: getInstance ( ) -> getSettings ( ) -> toArray ( ) ; $ newSettings = SimpleMap :: getInstance ( ) -> getSettings ( ) -> toArray ( ) ; $ craft2Settings = \ Craft :: $ app -> projectConfig -> get ( Plugins ...
Updates the plugins settings
50,630
private function _renderMap ( $ value , $ isSettings = false ) { $ view = Craft :: $ app -> getView ( ) ; $ containerId = $ this -> id . '-container' ; $ vueContainerId = $ view -> namespaceInputId ( $ containerId ) ; $ view -> registerJsFile ( 'https://polyfill.io/v3/polyfill.min.js?flags=gated&features=default%2CInte...
Renders the map input
50,631
protected function setAuthorAttribute ( $ items ) { if ( is_array ( $ items ) === false ) { return $ items ; } return array_map ( function ( $ item ) { return $ this -> getNestedContext ( Person :: class , $ item ) ; } , $ items ) ; }
Set the authors
50,632
protected function setReviewAttribute ( $ items ) { if ( is_array ( $ items ) === false ) { return $ items ; } return array_map ( function ( $ item ) { return $ this -> getNestedContext ( Review :: class , $ item ) ; } , $ items ) ; }
Set the reviews
50,633
protected function getContextTypeClass ( $ name ) { if ( class_exists ( $ name ) ) { return $ name ; } $ class = ucwords ( str_replace ( [ '-' , '_' ] , ' ' , $ name ) ) ; $ class = '\\JsonLd\\ContextTypes\\' . str_replace ( ' ' , '' , $ class ) ; if ( class_exists ( $ class ) ) { return $ class ; } switch ( $ name ) {...
Return script tag .
50,634
protected function setIsSimilarToAttribute ( $ values ) { if ( is_array ( $ values ) ) { foreach ( $ values as $ key => $ value ) { $ product = new self ( $ value ) ; $ properties = $ product -> getProperties ( ) ; unset ( $ properties [ '@context' ] ) ; $ properties = array_filter ( $ properties , 'strlen' ) ; $ value...
Set isSimilarTo attributes .
50,635
public function fill ( $ attributes ) { if ( $ this -> hasGetMutator ( 'type' ) ) { $ this -> type = $ this -> mutateAttribute ( 'type' , $ this -> getArrValue ( $ attributes , 'type' , $ this -> type ) ) ; } $ properties = array_merge ( [ '@context' => 'http://schema.org' , '@type' => $ this -> type , 'sameAs' => null...
Creates an array of schema . org attribute from attributes .
50,636
protected function setProperty ( $ key , $ property , $ value = null ) { if ( $ key [ 0 ] === '@' ) { return $ this -> properties [ $ key ] = $ property ; } if ( $ this -> hasGetMutator ( $ key ) ) { return $ this -> properties [ $ key ] = $ this -> mutateAttribute ( $ key , $ value ) ; } if ( $ value instanceof DateTi...
Set property value in attributes .
50,637
protected function getNestedContext ( $ class , $ attributes = null ) { if ( is_array ( $ attributes ) === false ) return $ attributes ; $ context = new $ class ( $ attributes ) ; return $ this -> filterNestedContext ( $ context -> getProperties ( ) ) ; }
Get nested context array .
50,638
protected function filterNestedContext ( array $ properties = [ ] ) { $ func = function ( $ value , $ key ) { return ( $ value && $ key !== '@context' ) ; } ; if ( ! defined ( 'ARRAY_FILTER_USE_BOTH' ) ) { $ return = [ ] ; foreach ( $ properties as $ k => $ v ) { if ( call_user_func ( $ func , $ v , $ k ) ) { $ return ...
Filter nested context array .
50,639
protected function mapProperty ( array $ template = [ ] , $ props = [ ] ) { if ( is_array ( $ props ) === false ) { return null ; } foreach ( $ template as $ key => $ value ) { if ( $ key [ 0 ] !== '@' ) { $ template [ $ key ] = $ this -> getArrValue ( $ props , $ key , '' ) ; } } return array_filter ( $ template ) ; }
Get property value from attributes .
50,640
protected function truncate ( $ string , $ limit , $ pad = '...' , $ break = ' ' ) { if ( strlen ( $ string ) <= $ limit ) return $ string ; if ( false !== ( $ breakpoint = strpos ( $ string , $ break , $ limit ) ) ) { if ( $ breakpoint < strlen ( $ string ) - 1 ) { $ string = substr ( $ string , 0 , $ breakpoint ) . $...
Trim a string to a given number of words
50,641
protected function setInAlbumAttribute ( $ items ) { if ( ! is_array ( $ items ) ) { return $ items ; } if ( ( count ( $ items ) == count ( $ items , COUNT_RECURSIVE ) ) ) { return $ this -> getNestedContext ( MusicAlbum :: class , $ items ) ; } return array_map ( function ( $ item ) { return $ this -> getNestedContext...
Set in album attribute
50,642
protected function setByArtistAttribute ( $ items ) { if ( ! is_array ( $ items ) ) { return $ items ; } if ( ( count ( $ items ) == count ( $ items , COUNT_RECURSIVE ) ) ) { return $ this -> getNestedContext ( MusicGroup :: class , $ items ) ; } return array_map ( function ( $ item ) { return $ this -> getNestedContex...
Set artist attribute
50,643
protected function setTrackAttribute ( $ items ) { if ( ! is_array ( $ items ) ) { return $ items ; } return array_map ( function ( $ item ) { return $ this -> getNestedContext ( MusicRecording :: class , $ item ) ; } , $ items ) ; }
Set the tracks for a music group
50,644
protected function setAddressAttribute ( $ items ) { if ( is_array ( $ items ) === false ) { return $ items ; } return $ this -> getNestedContext ( PostalAddress :: class , $ items ) ; }
Set the address
50,645
protected function setOffersAttribute ( $ values ) { if ( is_array ( $ values ) ) { foreach ( $ values as $ key => $ value ) { $ values [ $ key ] = $ this -> mapProperty ( [ 'name' => '' , 'price' => '' , 'url' => '' , ] , $ value ) ; } } return $ values ; }
Set offers attributes .
50,646
protected function setItemListElementAttribute ( $ items ) { foreach ( $ items as $ pos => $ item ) { $ items [ $ pos ] = $ this -> getNestedContext ( ListItem :: class , [ 'position' => $ pos + 1 , 'item' => $ item ] ) ; } return $ items ; }
Set the canonical URL of the article page .
50,647
protected function askForGraph ( ) { $ choices = array_map ( function ( $ name , $ config ) { return $ name . "\t(" . $ config [ 'class' ] . ' - ' . $ config [ 'graph' ] . ')' ; } , array_keys ( $ this -> config ) , $ this -> config ) ; $ choice = $ this -> choice ( 'Which state machine would you like to know about?' ,...
Ask for a graph name if one was not provided as argument .
50,648
protected function printTransitions ( array $ transitions ) { end ( $ transitions ) ; $ lastTransition = key ( $ transitions ) ; reset ( $ transitions ) ; $ rows = [ ] ; foreach ( $ transitions as $ name => $ transition ) { $ rows [ ] = [ $ name , implode ( PHP_EOL , $ transition [ 'from' ] ) , $ transition [ 'to' ] ] ...
Display the graph transitions on a table .
50,649
protected function printCallbacks ( array $ allCallbacks ) { foreach ( $ allCallbacks as $ position => $ callbacks ) { $ rows = [ ] ; foreach ( $ callbacks as $ name => $ specs ) { $ rows [ ] = [ $ name , $ this -> formatSatisfies ( $ specs ) , $ this -> formatCallable ( $ specs ) , $ this -> formatClause ( $ specs , '...
Display the graph callbacks on a table .
50,650
protected function formatSatisfies ( array $ specs ) { $ clauses = array_map ( function ( $ clause ) use ( $ specs ) { if ( $ result = $ this -> formatClause ( $ specs , $ clause ) ) { return vsprintf ( '%s: %s' , [ ucfirst ( str_replace ( '_' , ' ' , $ clause ) ) , $ result , ] ) ; } } , [ 'from' , 'excluded_from' , '...
Format the clauses that satisfy the callback .
50,651
protected function formatCallable ( array $ specs ) { if ( isset ( $ specs [ 'can' ] ) ) { $ callback = json_encode ( $ specs [ 'can' ] ) ; return "Gate::check({$callback})" ; } if ( ! isset ( $ specs [ 'do' ] ) ) { return '' ; } $ callback = $ specs [ 'do' ] ; if ( $ callback instanceof \ Closure ) { return 'Closure' ...
Format the callable callable .
50,652
public function setAttribute ( $ attribute , $ value ) { if ( $ this -> hasSetMutator ( $ attribute ) ) { $ method = 'set' . studly_case ( $ attribute ) . 'Attribute' ; return $ this -> { $ method } ( $ value ) ; } if ( array_key_exists ( $ attribute , $ this -> filterCustomCasts ( ) ) ) { $ customCastObject = $ this -...
Hook into setAttribute logic and enable our custom cast do the job .
50,653
protected function getCustomCastObject ( $ attribute ) { if ( isset ( $ this -> customCastObjects [ $ attribute ] ) ) { return $ this -> customCastObjects [ $ attribute ] ; } $ customCastClass = $ this -> casts [ $ attribute ] ; $ customCastObject = new $ customCastClass ( $ this , $ attribute ) ; return $ this -> cust...
Lazy load custom cast object and return it
50,654
public function getItagInfo ( $ itag ) { $ itag = '' . $ itag ; $ itags = $ this -> getItags ( ) ; if ( property_exists ( $ itags , $ itag ) ) return $ itags -> $ itag ; return null ; }
Gets information about a given itag
50,655
protected function getPlaylistIdFromUrl ( $ playlistUrl ) { $ playlistId = $ playlistUrl ; $ urlPart = parse_url ( $ playlistUrl ) ; if ( isset ( $ urlPart [ 'query' ] ) ) { $ query = $ this -> decodeString ( $ urlPart [ 'query' ] ) ; if ( isset ( $ query [ 'list' ] ) ) $ playlistId = $ query [ 'list' ] ; elseif ( isse...
Cuts playlist id from absolute Youtube playlist url
50,656
protected function getVideoIdFromUrl ( $ videoUrl ) { $ videoId = $ videoUrl ; $ urlPart = parse_url ( $ videoUrl ) ; $ path = $ urlPart [ 'path' ] ; if ( isset ( $ urlPart [ 'host' ] ) && strtolower ( $ urlPart [ 'host' ] ) == 'youtu.be' ) { if ( preg_match ( '/\/([^\/\?]*)/i' , $ path , $ temp ) ) $ videoId = $ temp ...
Cuts video id from absolute Youtube or youtu . be video url
50,657
public function getPlaylistInfo ( $ getDownloadLinks = false ) { try { $ url = 'https://www.youtube.com/list_ajax?style=json&action_get_list=1&list=' . $ this -> playlistId ; $ response = $ this -> webClient -> get ( $ url ) ; } catch ( \ Exception $ e ) { if ( $ e instanceof ClientException && $ e -> hasResponse ( ) )...
Gets information of Youtube playlist
50,658
protected function getUrl ( $ url ) { try { $ response = $ this -> webClient -> get ( $ url ) ; } catch ( \ Exception $ e ) { if ( $ e instanceof ClientException && $ e -> hasResponse ( ) ) throw new YoutubeException ( $ e -> getResponse ( ) -> getReasonPhrase ( ) , 3 ) ; else throw new YoutubeException ( $ e -> getMes...
Fetches content of passed URL
50,659
public function getInfo ( $ getDownloadLinks = false ) { try { if ( $ this -> isPlaylist ) return $ this -> getPlaylistInfo ( $ getDownloadLinks ) ; return $ this -> getVideoInfo ( $ getDownloadLinks ) ; } catch ( YoutubeException $ e ) { throw $ e ; } }
Gets information of Youtube video or playlist
50,660
protected function formatCaption ( $ captionLines , $ format = null ) { $ result = array ( ) ; $ result [ 'caption' ] = '' ; $ result [ 'extension' ] = 'txt' ; if ( $ format === null ) $ format = $ this -> captionFormat ; if ( $ format == 'srt' ) { $ result [ 'extension' ] = 'srt' ; $ sequence = 1 ; foreach ( $ caption...
Converts parsed caption track to desired caption format
50,661
protected function downloadCaption ( $ captions , $ language , $ filename ) { if ( $ language === null ) $ language = $ this -> defaultCaptionLanguage ; if ( ! array_key_exists ( $ language , $ captions ) ) $ captionData = array_shift ( $ captions ) ; else $ captionData = $ captions [ $ language ] ; $ captionData = $ t...
Downloads caption of the video in selected language
50,662
protected function getExtension ( $ mimetype ) { $ mime = new FlatRepository ; $ extension = 'mp4' ; $ extensions = $ mime -> findExtensions ( $ mimetype ) ; if ( count ( $ extensions ) ) $ extension = $ extensions [ 0 ] ; return $ extension ; }
Returns file extension of a given mime type
50,663
protected function downloadFile ( $ url , $ file , callable $ onProgress , callable $ onFinish ) { $ videoFile = fopen ( $ file , 'a' ) ; $ options = array ( 'sink' => $ videoFile , 'verify' => false , 'timeout' => 0 , 'connect_timeout' => 50 , 'progress' => $ onProgress , 'cookies' => new CookieJar ( false , [ [ 'url'...
Just downloads the given url
50,664
public function download ( $ itag = null , $ resume = false , $ caption = false ) { if ( $ itag === null && $ this -> defaultItag !== null ) $ itag = $ this -> defaultItag ; if ( ! $ this -> isPlaylist ) { try { $ this -> getVideoInfo ( true ) ; $ this -> downloadVideo ( $ itag , $ resume , $ caption ) ; } catch ( Yout...
Downloads video or playlist videos by given itag
50,665
protected function downloadVideo ( $ itag = null , $ resume = false , $ caption = false ) { if ( $ itag ) { foreach ( $ this -> videoInfo -> full_formats as $ video ) { if ( $ video -> itag == $ itag ) { try { $ this -> downloadFull ( $ video -> url , $ video -> filename , $ resume ) ; $ this -> finalize ( $ video -> f...
Downloads selected video by given itag
50,666
public function finalize ( $ filename , $ caption ) { $ canEditFile = false ; $ filePath = $ this -> path . DIRECTORY_SEPARATOR . $ filename ; $ file = null ; if ( $ this -> mp4EditingEnabled && strtolower ( pathinfo ( $ filename , PATHINFO_EXTENSION ) ) == 'mp4' ) { $ file = new Mp4 ( $ filePath ) ; $ canEditFile = tr...
Finalizes downloaded file
50,667
public function enableMp4Editing ( $ enable , $ autoClose = false ) { $ this -> mp4EditingEnabled = ! ! $ enable ; $ this -> autoCloseEditedMp4Files = ! ! $ autoClose ; }
Sets default caption format
50,668
protected function parseFloatTime ( $ time ) { $ result = array ( ) ; array_push ( $ result , fmod ( $ time , 60 ) ) ; $ time = intval ( $ time / 60 ) ; array_push ( $ result , fmod ( $ time , 60 ) ) ; $ time = intval ( $ time / 60 ) ; array_push ( $ result , fmod ( $ time , 60 ) ) ; return array_reverse ( $ result ) ;...
Sets downloaded videos path
50,669
public function setGenre ( $ genre ) { if ( is_numeric ( $ genre ) ) { $ this -> addOrChangeMetaData ( 'gnre' , $ this -> number ( $ genre + 1 , 16 ) ) ; } else $ this -> addOrChangeMetaData ( 'gen' , $ genre ) ; }
ID3v1Genres int or string
50,670
private function requestIsValid ( ) : bool { return $ this -> request -> has ( self :: OPENID_ASSOC_HANDLE ) && $ this -> request -> has ( self :: OPENID_SIGNED ) && $ this -> request -> has ( self :: OPENID_SIG ) ; }
Validates if the request object has required stream attributes .
50,671
public function validate ( ) : bool { if ( ! $ this -> requestIsValid ( ) ) { return false ; } $ requestOptions = $ this -> getDefaultRequestOptions ( ) ; $ customOptions = $ this -> getCustomRequestOptions ( ) ; if ( ! empty ( $ customOptions ) && is_array ( $ customOptions ) ) { $ requestOptions = array_merge ( $ req...
Checks the steam login .
50,672
public function getParams ( ) : array { $ params = [ 'openid.assoc_handle' => $ this -> request -> get ( self :: OPENID_ASSOC_HANDLE ) , 'openid.signed' => $ this -> request -> get ( self :: OPENID_SIGNED ) , 'openid.sig' => $ this -> request -> get ( self :: OPENID_SIG ) , 'openid.ns' => self :: OPENID_NS , 'openid.mo...
Get param list for openId validation .
50,673
public function parseResults ( $ results ) : Fluent { $ parsed = [ ] ; $ lines = explode ( "\n" , $ results ) ; foreach ( $ lines as $ line ) { if ( empty ( $ line ) ) { continue ; } $ line = explode ( ':' , $ line , 2 ) ; $ parsed [ $ line [ 0 ] ] = $ line [ 1 ] ; } return new Fluent ( $ parsed ) ; }
Parse openID response to fluent object .
50,674
private function buildUrl ( $ return = null ) : string { if ( is_null ( $ return ) ) { $ return = url ( '/' , [ ] , Config :: get ( 'steam-auth.https' ) ) ; } if ( ! is_null ( $ return ) && ! $ this -> validateUrl ( $ return ) ) { throw new RuntimeException ( 'The return URL must be a valid URL with a URI scheme or htt...
Build the Steam login URL .
50,675
public function parseSteamID ( ) : void { preg_match ( '#^https?://steamcommunity.com/openid/id/([0-9]{17,25})#' , $ this -> request -> get ( 'openid_claimed_id' ) , $ matches ) ; $ this -> steamId = is_numeric ( $ matches [ 1 ] ) ? $ matches [ 1 ] : 0 ; }
Parse the steamID from the OpenID response .
50,676
public function parseInfo ( ) : void { if ( is_null ( $ this -> steamId ) ) { return ; } if ( empty ( Config :: get ( 'steam-auth.api_key' ) ) ) { throw new RuntimeException ( 'The Steam API key has not been specified.' ) ; } $ response = $ this -> guzzleClient -> request ( 'GET' , sprintf ( self :: STEAM_INFO_URL , Co...
Get user data from steam api .
50,677
public static function fromText ( string $ wkt , int $ srid = 0 ) : Geometry { static $ wktReader ; if ( $ wktReader === null ) { $ wktReader = new WKTReader ( ) ; } $ geometry = $ wktReader -> read ( $ wkt , $ srid ) ; if ( ! $ geometry instanceof static ) { throw UnexpectedGeometryException :: unexpectedGeometryType ...
Builds a Geometry from a WKT representation .
50,678
public static function fromBinary ( string $ wkb , int $ srid = 0 ) : Geometry { static $ wkbReader ; if ( $ wkbReader === null ) { $ wkbReader = new WKBReader ( ) ; } $ geometry = $ wkbReader -> read ( $ wkb , $ srid ) ; if ( ! $ geometry instanceof static ) { throw UnexpectedGeometryException :: unexpectedGeometryTyp...
Builds a Geometry from a WKB representation .
50,679
public function asText ( ) : string { static $ wktWriter ; if ( $ wktWriter === null ) { $ wktWriter = new WKTWriter ( ) ; } return $ wktWriter -> write ( $ this ) ; }
Returns the WKT representation of this geometry .
50,680
public function asBinary ( ) : string { static $ wkbWriter ; if ( $ wkbWriter === null ) { $ wkbWriter = new WKBWriter ( ) ; } return $ wkbWriter -> write ( $ this ) ; }
Returns the WKB representation of this geometry .
50,681
public function relate ( Geometry $ geometry , string $ matrix ) : bool { return GeometryEngineRegistry :: get ( ) -> relate ( $ this , $ geometry , $ matrix ) ; }
Returns whether this geometry is spatially related to another geometry .
50,682
public function locateBetween ( float $ mStart , float $ mEnd ) : Geometry { return GeometryEngineRegistry :: get ( ) -> locateBetween ( $ this , $ mStart , $ mEnd ) ; }
Returns a derived geometry collection value that matches the specified range of m coordinate values inclusively .
50,683
public function withSRID ( int $ srid ) : Geometry { if ( $ srid === $ this -> SRID ( ) ) { return $ this ; } $ that = clone $ this ; $ that -> coordinateSystem = $ that -> coordinateSystem -> withSRID ( $ srid ) ; return $ that ; }
Returns a copy of this Geometry with the SRID altered .
50,684
public static function of ( Polygon $ patch1 , Polygon ... $ patchN ) : PolyhedralSurface { return new static ( $ patch1 -> coordinateSystem ( ) , $ patch1 , ... $ patchN ) ; }
Creates a non - empty PolyhedralSurface composed of the given patches .
50,685
public function patchN ( int $ n ) : Polygon { if ( ! isset ( $ this -> patches [ $ n - 1 ] ) ) { throw new NoSuchGeometryException ( 'There is no patch in this PolyhedralSurface at index ' . $ n ) ; } return $ this -> patches [ $ n - 1 ] ; }
Returns the specified patch N in this PolyhedralSurface .
50,686
private function read ( int $ words , int $ wordLength ) : string { $ length = $ words * $ wordLength ; if ( $ this -> position + $ length > $ this -> length ) { throw GeometryIOException :: invalidWKB ( 'unexpected end of stream' ) ; } if ( $ length === 1 ) { return $ this -> wkb [ $ this -> position ++ ] ; } if ( $ t...
Reads words from the buffer .
50,687
public function readByteOrder ( ) : void { $ byteOrder = $ this -> readUnsignedChar ( ) ; if ( $ byteOrder !== WKBTools :: BIG_ENDIAN && $ byteOrder !== WKBTools :: LITTLE_ENDIAN ) { throw GeometryIOException :: invalidWKB ( 'unknown byte order: ' . $ byteOrder ) ; } $ this -> invert = ( $ byteOrder !== $ this -> machi...
Reads the machine byte order from the buffer and stores the result to act accordingly .
50,688
public static function of ( Curve $ exteriorRing , Curve ... $ interiorRings ) : CurvePolygon { return new static ( $ exteriorRing -> coordinateSystem ( ) , $ exteriorRing , ... $ interiorRings ) ; }
Creates a non - empty CurvePolygon composed of the given rings .
50,689
public function interiorRingN ( int $ n ) : Curve { if ( $ n === 0 || ! isset ( $ this -> rings [ $ n ] ) ) { throw new NoSuchGeometryException ( 'There is no interior ring in this CurvePolygon at index ' . $ n ) ; } return $ this -> rings [ $ n ] ; }
Returns the specified interior ring N in this CurvePolygon .
50,690
public static function of ( Curve $ curve1 , Curve ... $ curveN ) : CompoundCurve { return new CompoundCurve ( $ curve1 -> coordinateSystem ( ) , $ curve1 , ... $ curveN ) ; }
Creates a non - empty CompoundCurve composed of the given curves .
50,691
public function curveN ( int $ n ) : Curve { if ( ! isset ( $ this -> curves [ $ n - 1 ] ) ) { throw new NoSuchGeometryException ( 'There is no Curve in this CompoundCurve at index ' . $ n ) ; } return $ this -> curves [ $ n - 1 ] ; }
Returns the specified Curve N in this CompoundCurve .
50,692
public static function xy ( float $ x , float $ y , int $ srid = 0 ) : Point { return new Point ( CoordinateSystem :: xy ( $ srid ) , $ x , $ y ) ; }
Creates a point with X and Y coordinates .
50,693
public static function xyz ( float $ x , float $ y , float $ z , int $ srid = 0 ) : Point { return new Point ( CoordinateSystem :: xyz ( $ srid ) , $ x , $ y , $ z ) ; }
Creates a point with X Y and Z coordinates .
50,694
public static function xym ( float $ x , float $ y , float $ m , int $ srid = 0 ) : Point { return new Point ( CoordinateSystem :: xym ( $ srid ) , $ x , $ y , $ m ) ; }
Creates a point with X Y and M coordinates .
50,695
public static function xyzm ( float $ x , float $ y , float $ z , float $ m , int $ srid = 0 ) : Point { return new Point ( CoordinateSystem :: xyzm ( $ srid ) , $ x , $ y , $ z , $ m ) ; }
Creates a point with X Y Z and M coordinates .
50,696
public static function of ( LineString $ exteriorRing , LineString ... $ interiorRings ) : Polygon { return new static ( $ exteriorRing -> coordinateSystem ( ) , $ exteriorRing , ... $ interiorRings ) ; }
Creates a non - empty Polygon composed of the given rings .
50,697
public function interiorRingN ( int $ n ) : LineString { if ( $ n === 0 || ! isset ( $ this -> rings [ $ n ] ) ) { throw new NoSuchGeometryException ( 'There is no interior ring in this Polygon at index ' . $ n ) ; } return $ this -> rings [ $ n ] ; }
Returns the specified interior ring N in this Polygon .
50,698
private function query ( string $ function , array $ parameters , bool $ returnsGeometry ) : array { $ queryParameters = [ ] ; foreach ( $ parameters as $ parameter ) { if ( $ parameter instanceof Geometry ) { if ( $ parameter -> isEmpty ( ) ) { $ queryParameters [ ] = 'ST_GeomFromText(?, ?)' ; } else { $ queryParamete...
Builds and executes a SQL query for a GIS function .
50,699
private function queryBoolean ( string $ function , ... $ parameters ) : bool { [ $ result ] = $ this -> query ( $ function , $ parameters , false ) ; if ( $ result === null || $ result === - 1 ) { throw GeometryEngineException :: operationYieldedNoResult ( ) ; } return ( bool ) $ result ; }
Queries a GIS function returning a boolean value .