idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
19,600
public static function addDecade ( $ ts = null , $ num = 1 ) { return sfTime :: add ( $ ts , $ num , sfTime :: DECADE ) ; }
Adds the specified number of decades to the timestamp .
19,601
public static function subtractDecade ( $ ts = null , $ num = 1 ) { return sfTime :: subtract ( $ ts , $ num , sfTime :: DECADE ) ; }
Subtracts the specified number of decades from the timestamp .
19,602
public static function addCentury ( $ ts = null , $ num = 1 ) { return sfTime :: add ( $ ts , $ num , sfTime :: CENTURY ) ; }
Adds the specified number of centuries to the timestamp .
19,603
public static function subtractCentury ( $ ts = null , $ num = 1 ) { return sfTime :: subtract ( $ ts , $ num , sfTime :: CENTURY ) ; }
Subtracts the specified number of centuries from the timestamp .
19,604
public static function addMillenium ( $ ts = null , $ num = 1 ) { return sfTime :: add ( $ ts , $ num , sfTime :: MILLENIUM ) ; }
Adds the specified number of millenia to the timestamp .
19,605
public static function subtractMillenium ( $ ts = null , $ num = 1 ) { return sfTime :: subtract ( $ ts , $ num , sfTime :: MILLENIUM ) ; }
Subtracts the specified number of millenia from the timestamp .
19,606
public static function firstDayOfWeek ( $ ts = null ) { if ( $ ts === null ) $ ts = sfDateTimeToolkit :: now ( ) ; return sfTime :: subtractDay ( $ ts , date ( 'w' , $ ts ) ) ; }
Returns the timestamp for first day of the week for the given date .
19,607
public static function finalDayOfWeek ( $ ts = null ) { return sfTime :: subtractDay ( sfTime :: firstDayOfWeek ( sfTime :: addWeek ( $ ts ) ) ) ; }
Returns the timestamp for last day of the week for the given date .
19,608
public static function firstDayOfMonth ( $ ts = null ) { if ( $ ts === null ) $ ts = sfDateTimeToolkit :: now ( ) ; return sfTime :: subtractDay ( $ ts , date ( 'd' , $ ts ) - 1 ) ; }
Returns the timestamp for first day of the month for the given date .
19,609
public static function finalDayOfMonth ( $ ts = null ) { return sfTime :: subtractDay ( sfTime :: firstDayOfMonth ( sfTime :: addMonth ( $ ts ) ) ) ; }
Returns the timestamp for last day of the month for the given date .
19,610
public static function firstDayOfQuarter ( $ ts = null ) { if ( $ ts === null ) $ ts = sfDateTimeToolkit :: now ( ) ; $ month = date ( 'm' , $ ts ) ; $ quarter = ceil ( $ month / 3 ) - 1 ; return sfTime :: subtractMonth ( sfTime :: firstDayOfMonth ( $ ts ) , $ month - ( $ quarter * 3 ) - 1 ) ; }
Returns the timestamp for first day of thequarter for the given date .
19,611
public static function finalDayOfQuarter ( $ ts = null ) { return sfTime :: subtractDay ( sfTime :: firstDayOfQuarter ( sfTime :: addQuarter ( $ ts ) ) ) ; }
Returns the timestamp for last day of the quarter for the given date .
19,612
public static function firstDayOfYear ( $ ts = null ) { if ( $ ts === null ) $ ts = sfDateTimeToolkit :: now ( ) ; return sfTime :: subtractMonth ( sfTime :: firstDayOfMonth ( $ ts ) , date ( 'm' , $ ts ) - 1 ) ; }
Returns the timestamp for first day of the year for the given date .
19,613
public static function finalDayOfYear ( $ ts = null ) { return sfTime :: subtractDay ( sfTime :: firstDayOfYear ( sfTime :: addYear ( $ ts ) ) ) ; }
Returns the timestamp for last day of the year for the given date .
19,614
public function getAuth ( $ errorOnNull = false ) { if ( $ errorOnNull && ! $ this -> auth ) { $ msg = 'No Auth object provided. (HINT: Set your Auth data using ' . '"$API->setAuth(Auth $auth)" or $API\' constructor. ' . 'See https://TODO for details.' ; throw new ApiException ( $ msg ) ; } return $ this -> auth ; }
Get the authentication object .
19,615
private function validateApiParameters ( $ keys = null , $ params = null ) { $ this -> assertApiId ( ) ; $ this -> assertKeysArrayValid ( $ keys ) ; $ this -> assertKeysHasMinOptParams ( $ keys , $ params ) ; $ params = $ this -> setAuthenticationParameters ( $ keys , $ params , 'req' ) ; $ params = $ this -> setAuthen...
Validate authentication and argument parameters for an API .
19,616
private function assertKeysArrayValid ( $ keys = null ) { if ( ( ! $ keys ) || ( ! is_array ( $ keys ) ) || ( ! isset ( $ keys [ 'auth' ] ) ) || ( ! is_array ( $ keys [ 'auth' ] ) ) || ( ! isset ( $ keys [ 'auth' ] [ 'req' ] ) ) || ( ! is_array ( $ keys [ 'auth' ] [ 'req' ] ) ) || ( ! isset ( $ keys [ 'auth' ] [ 'opt' ...
Assert required API keys exist and are valid .
19,617
private function setAuthenticationParameters ( $ keys = null , $ params = null , $ type = 'req' ) { if ( ! empty ( $ keys [ 'auth' ] [ $ type ] ) ) { if ( $ this -> auth == null ) { $ msg = 'No Auth object provided. (HINT: Set your Auth data using ' . '"$API->setAuth(Auth $auth)" or $API\' constructor. ' . 'See https...
Validate and set required authentication parameters from Auth object .
19,618
private function assertReqParameters ( $ keys , $ params = null ) { if ( ! empty ( $ keys [ 'args' ] [ 'req' ] ) ) { if ( ! $ params ) { $ msg = 'No parameters provided. (HINT: Reference the $keys ' . 'property at the top of the API class file for ' . 'required and optional parameters.)' ; throw new ApiException ( $ ms...
Validate required parameters for API .
19,619
private function removeUnknownParameters ( $ keys , $ params ) { $ valid_keys = array_merge ( $ keys [ 'auth' ] [ 'req' ] , $ keys [ 'auth' ] [ 'opt' ] , $ keys [ 'args' ] [ 'req' ] , $ keys [ 'args' ] [ 'opt' ] ) ; foreach ( $ params as $ k => $ v ) { if ( ! in_array ( $ k , $ valid_keys ) ) { unset ( $ params [ $ k ]...
Strip parameters not defined in API keys array .
19,620
public function request ( $ method , $ url , $ params = null ) { if ( ! $ params ) { $ params = array ( ) ; } else { $ params = self :: encodeObjects ( $ params ) ; } if ( in_array ( 'request' , $ this -> config [ 'dataResponse' ] ) ) { $ this -> state [ 'request' ] [ 'body' ] = $ params ; } $ this -> debug_echo ( "\nR...
Send an API request interpret and return the response .
19,621
private function curlRequest ( $ method , $ absUrl , $ params ) { $ result = array ( ) ; $ opts = array ( ) ; $ curl = curl_init ( ) ; if ( $ method == 'post' ) { $ opts [ CURLOPT_POST ] = 1 ; $ opts [ CURLOPT_POSTFIELDS ] = $ params ; } else { throw new ApiException ( 'Unsupported method ' . $ method , $ this -> state...
Send a JSON or XML CURL request .
19,622
private function interpretResponseJSON ( ) { $ this -> debug_echo ( "\n\nResponse (json):\n" ) ; $ this -> debug_print_r ( $ this -> state [ 'response' ] [ 'body_raw' ] ) ; if ( $ this -> config [ 'dataFormat' ] == 'array' ) { try { $ this -> state [ 'response' ] [ 'body' ] = json_decode ( $ this -> state [ 'response' ...
Process a JSON CURL response .
19,623
private function interpretResponseXML ( ) { $ this -> debug_echo ( "\n\nResponse (xml):\n" . $ this -> state [ 'response' ] [ 'body_raw' ] ) ; $ this -> state [ 'response' ] [ 'body' ] = $ this -> state [ 'response' ] [ 'body_raw' ] ; if ( $ this -> state [ 'response' ] [ 'code' ] < 200 || $ this -> state [ 'response' ...
Process a XML CURL response .
19,624
private function handleCurlError ( $ errno , $ message ) { $ apiBase = $ this -> apiBase ; switch ( $ errno ) { case CURLE_COULDNT_CONNECT : case CURLE_COULDNT_RESOLVE_HOST : case CURLE_OPERATION_TIMEOUTED : $ msg = 'Could not connect to MyAllocator (' . $ apiBase . '). ' . 'Please check your internet connection and tr...
Handle a CURL error resulting from a request .
19,625
private function handleHttpError ( ) { $ msg = 'HTTP API Error (HTTP response code was ' . $ this -> state [ 'response' ] [ 'code' ] . ')' ; switch ( $ this -> state [ 'response' ] [ 'code' ] ) { case 404 : throw new InvalidRequestException ( $ msg , $ this -> state ) ; case 401 : throw new ApiAuthenticationException (...
Handle a HTTP error resulting from a request .
19,626
private function apiUrl ( $ url = '' , $ format = 'json' ) { if ( ! $ url ) { return false ; } $ absUrl = sprintf ( 'https://%s/pms/v%d/%s/%s' , $ this -> apiBase , $ this -> version , $ format , $ url ) ; return ( string ) $ absUrl ; }
Get the absolute URL for an API request .
19,627
private static function encodeObjects ( $ d ) { if ( $ d instanceof Api ) { return self :: utf8 ( Common :: getClassName ( get_class ( $ d ) ) ) ; } else if ( $ d === true ) { return 'true' ; } else if ( $ d === false ) { return 'false' ; } else if ( is_array ( $ d ) ) { $ res = array ( ) ; foreach ( $ d as $ k => $ v ...
Encode an object .
19,628
private function formatResponse ( ) { $ return = array ( ) ; if ( isset ( $ this -> state [ 'method' ] ) ) { $ return [ 'method' ] = $ this -> state [ 'method' ] ; } if ( ! empty ( $ this -> state [ 'request' ] ) ) { $ return [ 'request' ] = $ this -> state [ 'request' ] ; } if ( ! empty ( $ this -> state [ 'response' ...
Format a response from available state data .
19,629
public function handleEncode ( EncodeValueEvent $ event ) { $ definition = $ event -> getValue ( ) ; if ( ! $ definition instanceof Definition ) { return ; } $ type = $ definition -> getType ( ) ; $ method = 'encode' . $ this -> convertTypeToMethod ( $ type ) ; if ( method_exists ( $ this , $ method ) ) { $ buffer = $ ...
Handle compile event .
19,630
public function handleGetReference ( EncodeReferenceEvent $ event ) { $ definition = $ event -> getObject ( ) ; if ( $ definition instanceof Definition ) { $ this -> setReference ( $ definition , $ event ) ; } }
Handle get reference event .
19,631
private function convertTypeToMethod ( $ type ) { $ parts = explode ( '.' , str_replace ( [ '-' , '_' ] , '.' , $ type ) ) ; $ parts = array_map ( 'ucfirst' , $ parts ) ; return implode ( '' , $ parts ) ; }
Convert definition type to method name .
19,632
protected function getReferences ( array $ values , Encoder $ encoder ) { return array_map ( function ( $ value ) use ( $ encoder ) { return $ encoder -> encodeReference ( $ value ) ; } , $ values ) ; }
Get references of given values .
19,633
public function newAuthorizeRequest ( $ type , $ typeId , $ authParams = [ ] ) { if ( $ this -> authorizationServer -> hasGrantType ( 'authorization_code' ) ) { $ authGrant = $ this -> authorizationServer -> getGrantType ( 'authorization_code' ) ; return $ authGrant -> newAuthorizeRequest ( $ type , $ typeId , $ authPa...
Parse a new authorize request
19,634
public function encodeGeoJson ( GeoJson $ geoJson , Encoder $ encoder ) { $ buffer = sprintf ( '%s = L.geoJson(%s, %s);' , $ encoder -> encodeReference ( $ geoJson ) , $ encoder -> encodeValue ( $ geoJson -> getInitializationData ( ) ) , $ encoder -> encodeValue ( $ geoJson -> getOptions ( ) ) ) ; foreach ( $ geoJson -...
Encode a feature group .
19,635
private function doGroupEncode ( $ type , LayerGroup $ group , Encoder $ encoder ) { return sprintf ( '%s = L.%s(%s);' , $ encoder -> encodeReference ( $ group ) , $ type , $ this -> encodeLayersInformation ( $ group -> getLayers ( ) , $ encoder ) ) ; }
Encode the group .
19,636
private function encodeLayersInformation ( $ layers , Encoder $ encoder ) { $ layers = array_map ( function ( $ layer ) use ( $ encoder ) { return $ encoder -> encodeReference ( $ layer ) ; } , $ layers ) ; return '[' . implode ( ', ' , $ layers ) . ']' ; }
Get layer information correctly encoded .
19,637
public function enableOffline ( ) { $ this -> settings [ 'offline' ] = $ this -> data [ 'offline_interval' ] === 'unlimited' ? true : strtotime ( '+' . intval ( $ this -> data [ 'offline_value' ] ) . ' ' . $ this -> data [ 'offline_interval' ] ) ; $ this -> touch ( false ) ; }
Enables offline mode .
19,638
public static function fromArray ( array $ native ) { if ( ! isset ( $ native [ 0 ] ) || ! isset ( $ native [ 1 ] ) ) { throw new \ InvalidArgumentException ( 'LatLngBounds array format not supported.' ) ; } return new static ( LatLng :: fromArray ( $ native [ 0 ] ) , LatLng :: fromArray ( $ native [ 1 ] ) ) ; }
Create from native array format .
19,639
public static function fromString ( $ native , $ separator = ',' ) { $ values = explode ( $ separator , $ native , 4 ) ; if ( count ( $ values ) !== 4 ) { throw new \ InvalidArgumentException ( sprintf ( 'LatLngBounds can not be created from string "%s"' , $ native ) ) ; } return new LatLngBounds ( new LatLng ( $ value...
Create from a string format .
19,640
public function getCenter ( ) { return new LatLng ( ( $ this -> getNorth ( ) - $ this -> getSouth ( ) ) , ( $ this -> getWest ( ) - $ this -> getEast ( ) ) ) ; }
Get the center .
19,641
public function equals ( LatLngBounds $ other ) { if ( ! $ this -> getNorthEast ( ) -> equals ( $ other -> getNorthEast ( ) ) ) { return false ; } return $ this -> getSouthWest ( ) -> equals ( $ other -> getSouthWest ( ) ) ; }
Compare two bounds .
19,642
public function overlaps ( LatLngBounds $ other ) { $ southWest = $ other -> getSouthWest ( ) ; $ northEast = $ other -> getNorthEast ( ) ; $ latOverlaps = ( $ northEast -> getLatitude ( ) > $ this -> southWest -> getLatitude ( ) ) && ( $ southWest -> getLatitude ( ) < $ this -> northEast -> getLatitude ( ) ) ; $ lngOv...
Check if bounds overlaps .
19,643
public function contains ( $ object ) { if ( $ object instanceof LatLng ) { $ lat = $ object -> getLatitude ( ) ; $ lng = $ object -> getLongitude ( ) ; if ( $ this -> getWest ( ) > $ lng || $ this -> getEast ( ) < $ lng ) { return false ; } return ( $ this -> getSouth ( ) <= $ lat && $ this -> getNorth ( ) >= $ lat ) ...
Check if given object in in the bounds .
19,644
public function registerStylesheet ( $ name , $ source , $ type = Assets :: TYPE_FILE ) { $ this -> stylesheets [ $ name ] [ ] = array ( $ source , $ type ) ; return $ this ; }
Register a stylesheet for the library .
19,645
public function registerJavascript ( $ name , $ source , $ type = Assets :: TYPE_FILE ) { $ this -> javascripts [ $ name ] [ ] = array ( $ source , $ type ) ; return $ this ; }
Register a javascript for the library .
19,646
public function build ( Map $ map , Assets $ assets = null ) { $ prefix = 'var map, layers = {}, controls = {}, icons = {};' . "\n" ; if ( ! $ assets ) { return $ prefix . $ this -> javascriptBuilder -> encode ( $ map , $ this -> jsonEncodeFlags ) ; } $ collector = new Collector ( $ assets , $ this -> javascripts , $ t...
Build map as a javascript resource .
19,647
public function getOutput ( ) { $ this -> lines = array ( ) ; $ this -> addLine ( 'BEGIN:VCALENDAR' ) ; $ this -> addLine ( 'VERSION:2.0' ) ; if ( is_null ( $ this -> prodid ) ) { $ this -> addLine ( "PRODID:" . '-//' . $ this -> host . '//NONSGML v1.0//EN' ) ; } elseif ( ! is_null ( $ this -> prodid ) ) { $ this -> ad...
Get the calendar as a string .
19,648
protected function getFormatedDateTime ( Date $ date = null , Time $ time = null ) { $ timestamp = null ; if ( $ date && $ time ) { $ timestamp = strtotime ( $ date . ' ' . $ time ) ; } else { $ timestamp = time ( ) ; } return gmdate ( 'Ymd\THis\Z' , $ timestamp ) ; }
Get an ical formatted datetime string .
19,649
protected function addDateTime ( CalendarDateTime $ dateTime ) { $ this -> addLine ( 'BEGIN:VEVENT' ) ; $ this -> addLine ( 'UID:' . $ this -> getUID ( $ dateTime ) ) ; $ this -> addLine ( 'DTSTAMP;TZID=' . Calendar :: config ( ) -> timezone . ':' . $ this -> getFormatedDateTime ( ) ) ; $ this -> addLine ( 'DTSTART;TZI...
Add a CalendarDateTime to the stack .
19,650
public function setCenter ( $ center ) { if ( ! $ center instanceof LatLng ) { $ center = LatLng :: fromNative ( $ center ) ; } Assertion :: isInstanceOf ( $ center , 'Netzmacht\LeafletPHP\Value\LatLng' ) ; return $ this -> setOption ( 'center' , $ center ) ; }
Set the center .
19,651
public function removeControl ( Control $ control ) { $ key = array_search ( $ control , $ this -> controls ) ; if ( $ key !== false ) { unset ( $ this -> controls [ $ key ] ) ; } return $ this ; }
Remove a control from the map .
19,652
public function setMaxBounds ( $ bounds ) { if ( is_array ( $ bounds ) ) { $ bounds = LatLngBounds :: fromArray ( $ bounds ) ; } Assertion :: isInstanceOf ( $ bounds , 'Netzmacht/LeafletPHP/Type/LatLngBounds' ) ; return $ this -> setOption ( 'maxBounds' , $ bounds ) ; }
Set max bounds option .
19,653
public function setLatLng ( $ latLng ) { if ( ! $ latLng instanceof LatLng ) { $ latLng = LatLng :: fromNative ( $ latLng ) ; } $ this -> latLng = $ latLng ; return $ this ; }
Set coordinates of the marker .
19,654
public function toGeoJsonFeature ( ) { $ feature = new Feature ( $ this , $ this -> getId ( ) ) ; $ options = $ this -> getOptions ( ) ; if ( $ this -> getIcon ( ) ) { $ feature -> setProperty ( 'icon' , $ this -> getIcon ( ) -> getId ( ) ) ; unset ( $ options [ 'icon' ] ) ; } $ feature -> setProperty ( 'options' , $ o...
Get marker as geo json feature .
19,655
public function toHTML ( $ separator = '<br/>' ) { $ output = '' ; foreach ( $ this -> diff as $ entry ) { $ element = '' ; if ( $ entry instanceof UnmodifiedEntry ) { $ element = 'span' ; } elseif ( $ entry instanceof DeletedEntry ) { $ element = 'del' ; } elseif ( $ entry instanceof InsertedEntry ) { $ element = 'ins...
Render diff to HTML
19,656
public static function compress ( $ html ) { $ filters = array ( '/(?:<script[^>]*>|\G(?!\A))(?:[^\'"\/<]+|"(?:[^\\"]+|\\.)*"|\'(?:[^\\\']+|\\.)*\'|\/(?!\/)|<(?!\/script))*+\K\/\/[^\n|<]*/xsu' => '' , '/<!--(?!\s*(?:\[if [^\]]+]|<!|>))(?:(?! => '' , '/\/+?\s*\*[\s\S]*?\*\s*\/+/u' => '' , '/>\s{2,}</u' => '><' , '/\s{2,...
HTML compress function .
19,657
function score ( $ phone_number , $ account_lifecycle_event , array $ other = [ ] ) { return $ this -> post ( sprintf ( self :: SCORE_RESOURCE , $ phone_number ) , array_merge ( $ other , [ "account_lifecycle_event" => $ account_lifecycle_event ] ) ) ; }
Score is an API that delivers reputation scoring based on phone number intelligence traffic patterns machine learning and a global data consortium .
19,658
public function parseArguments ( array $ args ) { $ this -> action = null ; $ this -> arguments = array ( ) ; $ parsed = array ( ) ; $ argument = reset ( $ args ) ; while ( $ argument ) { if ( strpos ( $ argument , '=' ) > 0 ) { $ arg = explode ( '=' , $ argument ) ; $ argKey = ltrim ( $ arg [ 0 ] , '-' ) ; $ argValue ...
Parse the CLI request arguments into a normalized format .
19,659
private function switchUser ( ) { if ( isset ( $ this -> user ) && function_exists ( 'posix_getpwnam' ) ) { $ current_user = @ posix_getpwuid ( @ posix_getuid ( ) ) ; if ( ! is_array ( $ current_user ) ) { $ this -> log ( "user switch to {$this->user} failed: could not determine current username" ) ; return false ; } i...
Switch the user executing the current process .
19,660
public function get ( $ key , $ options = null , $ default = null , $ filter = null ) { $ value = $ default ; if ( is_array ( $ options ) && array_key_exists ( $ key , $ options ) ) { $ value = $ options [ $ key ] ; } elseif ( array_key_exists ( $ key , $ this -> config ) ) { $ value = $ this -> config [ $ key ] ; } if...
Get a Config option value .
19,661
public function find ( $ search = null ) { $ results = array ( ) ; if ( empty ( $ search ) ) { $ results = $ this -> config ; } elseif ( is_scalar ( $ search ) ) { $ results = array_filter ( $ this -> config , function ( $ value , $ key ) use ( $ search ) { return strpos ( $ key , $ search ) !== false ; } ) ; } elseif ...
Find Config options by searching the keys .
19,662
public function compile ( $ name = 'teleport.phar' ) { $ this -> cleanse ( $ name ) ; $ this -> getVersion ( ) ; echo "building {$name} version {$this->version} ({$this->versionDate})" . PHP_EOL ; $ phar = $ this -> preparePhar ( $ name ) ; $ this -> addSrc ( $ phar ) ; $ this -> addTpl ( $ phar ) ; $ this -> addAutolo...
Compile Teleport into a Phar for distribution .
19,663
private function preparePhar ( $ name ) { $ phar = new \ Phar ( $ name , 0 , $ this -> alias ) ; $ phar -> setSignatureAlgorithm ( \ Phar :: SHA1 ) ; $ phar -> startBuffering ( ) ; return $ phar ; }
Prepare a phar object for adding files .
19,664
private function addAutoload ( $ phar ) { $ this -> addFile ( $ phar , new \ SplFileInfo ( $ this -> path . '/vendor/autoload.php' ) ) ; $ this -> addFile ( $ phar , new \ SplFileInfo ( $ this -> path . '/vendor/composer/autoload_classmap.php' ) ) ; $ this -> addFile ( $ phar , new \ SplFileInfo ( $ this -> path . '/ve...
Add the Composer autoload infrastructure .
19,665
private function addLicense ( $ phar ) { if ( is_readable ( $ this -> path . '/LICENSE' ) ) { $ this -> addFile ( $ phar , new \ SplFileInfo ( $ this -> path . '/LICENSE' ) , false ) ; } }
Add the LICENSE file if it exists .
19,666
function phoneid ( $ phone_number , array $ fields = [ ] ) { return $ this -> post ( sprintf ( self :: PHONEID_RESOURCE , $ phone_number ) , $ fields ) ; }
The PhoneID API provides a cleansed phone number phone type and telecom carrier information to determine the best communication method - SMS or voice .
19,667
public static function instance ( array $ options = array ( ) , $ forceNew = false ) { if ( self :: $ instance === null || $ forceNew === true ) { self :: $ instance = new Endpoint ( $ options ) ; } else { self :: $ instance -> setConfig ( $ options ) ; } return self :: $ instance ; }
Get a singleton instance of the Teleport Endpoint listener .
19,668
private function _createCurlHandle ( ) { if ( ! $ this -> isSupported ( ) ) { $ this -> logger -> error ( "cURL extension not found (or not enabled)." ) ; throw new UnsupportedException ( 'cURL extension not found (or not enabled).' ) ; } $ this -> logger -> info ( "cURL extension is loaded." ) ; $ curl = curl_init ( )...
Build a cURL resource with basic configurations already made
19,669
public function get ( $ url ) { $ curl = $ this -> _createCurlHandle ( ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ curl , CURLOPT_HEADER , true ) ; curl_setopt ( $ curl , CURLOPT_POST , 0 ) ; curl_setopt ( $ curl , CURLOPT_URL , $ url ) ; $ response = curl_exec ( $ curl ) ; $ code = cur...
Perform a GET request using a cURL handle
19,670
static function generateTelesignHeaders ( $ customer_id , $ api_key , $ method_name , $ resource , $ url_encoded_fields , $ date = null , $ nonce = null , $ user_agent = null , $ content_type = null ) { if ( ! $ date ) { $ date = gmdate ( "D, d M Y H:i:s T" ) ; } if ( ! $ nonce ) { $ nonce = Uuid :: uuid4 ( ) -> toStri...
Generates the TeleSign REST API headers used to authenticate requests .
19,671
protected function execute ( $ method_name , $ resource , $ fields = [ ] , $ date = null , $ nonce = null ) { $ url_encoded_fields = http_build_query ( $ fields , null , "&" ) ; $ headers = $ this -> generateTelesignHeaders ( $ this -> customer_id , $ this -> api_key , $ method_name , $ resource , $ url_encoded_fields ...
Generic TeleSign REST API request handler
19,672
public function addEntry ( AbstractEntry $ entry , $ prepend = false ) { if ( $ prepend ) { array_unshift ( $ this -> entries , $ entry ) ; } else { $ this -> entries [ ] = $ entry ; } }
Add new entry to group
19,673
protected function getAdapter ( ) { if ( ! $ this -> adapter ) { $ this -> adapter = new Curl ( ) ; $ this -> adapter -> setLogger ( new NullLogger ( ) ) ; } return $ this -> adapter ; }
Return the adapter being used to connect to the remote server
19,674
public function process ( ) { parent :: process ( ) ; try { if ( ! array_key_exists ( 'config_key' , $ this -> request -> args ( ) ) ) { $ this -> config_key = 'config' ; } if ( ! array_key_exists ( 'code' , $ this -> request -> args ( ) ) ) { $ this -> code = str_replace ( array ( '-' , '.' ) , array ( '_' , '_' ) , $...
Process this action .
19,675
function status ( $ external_id , array $ params = [ ] ) { return $ this -> get ( sprintf ( self :: APPVERIFY_STATUS_RESOURCE , $ external_id ) , $ params ) ; }
Retrieves the verification result for an App Verify transaction by external_id . To ensure a secure verification flow you must check the status using TeleSign s servers on your backend . Do not rely on the SDK alone to indicate a successful verification .
19,676
public static function loadProfile ( $ profile ) { $ decoded = json_decode ( file_get_contents ( $ profile ) ) ; if ( ! empty ( $ decoded -> code ) ) { $ decoded -> code = str_replace ( array ( '-' , '.' ) , array ( '_' , '_' ) , $ decoded -> code ) ; } else { throw new InvalidProfileException ( "Error getting 'code' f...
Load JSON profile data into a PHP stdObject instance .
19,677
public function getMODX ( $ profile = null , array $ options = array ( ) , array & $ results = array ( ) ) { if ( $ profile === null && ! $ this -> modx instanceof \ modX ) { throw new InvalidMODXException ( "No profile or MODX instance was provided" ) ; } if ( ! $ this -> modx instanceof \ modX ) { try { define ( 'MOD...
Get a MODX reference for Teleport to operate on .
19,678
public function setMODX ( \ modX $ modx , array $ options = array ( ) ) { if ( $ this -> modx instanceof \ modX ) { throw new InvalidMODXException ( 'MODX already set; you cannot set another MODX instance' ) ; } if ( ! $ modx instanceof \ modX ) { throw new InvalidMODXException ( 'Attempt to set an invalid MODX instanc...
Set a MODX instance to use with Teleport explicitly .
19,679
public function & getRequest ( $ requestClass = '' ) { if ( ! is_string ( $ requestClass ) || $ requestClass === '' ) { $ requestClass = $ this -> getConfig ( ) -> get ( 'Request.class' , null , 'Teleport\Request\CLIRequest' ) ; } if ( ! $ this -> request instanceof $ requestClass ) { $ this -> request = new $ requestC...
Get a Teleport Request object of a specific class .
19,680
protected function registerStreamHandlers ( ) { $ handlers = $ this -> getConfig ( ) -> get ( 'stream_handlers' , null , array ( ) ) ; if ( ! is_array ( $ handlers ) ) { throw new ConfigException ( 'Invalid stream_handlers configuration' , E_USER_ERROR ) ; } $ defaultStreamContext = array ( ) ; foreach ( $ handlers as ...
Register stream handlers specified in the Teleport Config .
19,681
function call ( $ phone_number , $ message , $ message_type , array $ other = [ ] ) { return $ this -> post ( self :: VOICE_RESOURCE , array_merge ( $ other , [ "phone_number" => $ phone_number , "message" => $ message , "message_type" => $ message_type ] ) ) ; }
Send a voice call to the target phone_number .
19,682
function status ( $ reference_id , array $ params = [ ] ) { return $ this -> get ( sprintf ( self :: VOICE_STATUS_RESOURCE , $ reference_id ) , $ params ) ; }
Retrieves the current status of the voice call .
19,683
public function & getMODX ( $ profile ) { if ( ! $ this -> modx instanceof \ modX ) { $ results = $ this -> request -> getResults ( ) ; $ this -> modx = Teleport :: instance ( ) -> getMODX ( $ profile , $ this -> request -> args ( ) , $ results ) ; } return $ this -> modx ; }
Get a MODX reference to operate on .
19,684
public function validate ( ) { if ( ! empty ( $ this -> required ) ) { $ invalid = array_diff ( $ this -> required , array_keys ( $ this -> request -> args ( ) ) ) ; if ( ! empty ( $ invalid ) ) { foreach ( $ invalid as $ argKey ) { $ this -> request -> addResult ( "{$argKey} required for this request." ) ; } throw new...
Validate the arguments specified for this Action .
19,685
public function pull ( $ source , $ target ) { $ pulled = false ; if ( $ this -> modx -> getCacheManager ( ) ) { $ pulled = $ this -> modx -> cacheManager -> copyFile ( $ source , $ target , array ( 'copy_preserve_permissions' => true ) ) ; } return $ pulled ; }
Pull a source to a specified target location .
19,686
public function push ( $ source , $ target ) { $ pushed = false ; if ( $ this -> modx -> getCacheManager ( ) ) { $ pushed = $ this -> modx -> cacheManager -> copyFile ( $ source , $ target , array ( 'copy_preserve_permissions' => true ) ) ; } return $ pushed ; }
Push a source to a specified target location .
19,687
public function get ( $ url ) { if ( ! $ this -> isSupported ( ) ) { $ this -> logger -> error ( "allow_url_fopen is disabled." ) ; throw new UnsupportedException ( 'allow_url_fopen disabled.' ) ; } $ this -> logger -> info ( "allow_url_fopen is enabled." ) ; $ context = stream_context_create ( array ( 'http' => array ...
Perform a GET request using a file handle
19,688
private function square ( $ x , $ y , $ size , $ offset ) { $ a = $ this -> getCellHeight ( $ x - $ size , $ y - $ size , $ size ) ; $ b = $ this -> getCellHeight ( $ x + $ size , $ y + $ size , $ size ) ; $ c = $ this -> getCellHeight ( $ x - $ size , $ y + $ size , $ size ) ; $ d = $ this -> getCellHeight ( $ x + $ s...
Definition of height middle point in square
19,689
private function diamond ( $ x , $ y , $ size , $ offset ) { $ a = $ this -> getCellHeight ( $ x , $ y - $ size , $ size ) ; $ b = $ this -> getCellHeight ( $ x , $ y + $ size , $ size ) ; $ c = $ this -> getCellHeight ( $ x - $ size , $ y , $ size ) ; $ d = $ this -> getCellHeight ( $ x + $ size , $ y , $ size ) ; $ a...
Definition of height middle point in diamond
19,690
private function getOffset ( $ stepSize ) { $ stepOffset = $ stepSize / $ this -> size * mt_rand ( - $ this -> size , $ this -> size ) ; $ sign = $ stepOffset < 0 ? - 1 : 1 ; return $ sign * pow ( abs ( $ stepOffset ) , 1 / sqrt ( $ this -> getPersistence ( ) ) ) ; }
Getting random displacement
19,691
private function getCellHeight ( $ x , $ y , $ stepSize = 0 ) { try { return $ this -> terra [ $ x ] [ $ y ] ; } catch ( Exception $ e ) { return $ this -> getOffset ( $ stepSize ) ; } }
return point height if point exists else random height
19,692
public function process ( ) { parent :: process ( ) ; try { $ this -> profile = Teleport :: loadProfile ( $ this -> profile ) ; $ this -> getMODX ( $ this -> profile ) ; $ this -> modx -> setOption ( \ xPDO :: OPT_SETUP , true ) ; $ this -> modx -> loadClass ( 'transport.xPDOTransport' , XPDO_CORE_PATH , true , true ) ...
Process the Inject action .
19,693
public function run ( $ port ) { $ port = ( integer ) $ port ; if ( $ port < 1 ) { throw new \ RuntimeException ( "Invalid port specified for Teleport HTTP Server" , E_USER_ERROR ) ; } $ loop = \ React \ EventLoop \ Factory :: create ( ) ; $ socket = new \ React \ Socket \ Server ( $ loop ) ; $ http = new \ React \ Htt...
Run the Teleport HTTP Server on the specified port .
19,694
public function process ( ) { parent :: process ( ) ; try { $ this -> profile = Teleport :: loadProfile ( $ this -> profile ) ; $ this -> getMODX ( $ this -> profile ) ; $ this -> tpl = $ this -> loadTpl ( $ this -> tpl ) ; $ this -> package = $ this -> createPackage ( $ this -> getName ( ) , $ this -> getVersion ( ) ,...
Process the Extract action .
19,695
protected function loadTpl ( $ tpl ) { $ this -> tplBase = $ this -> request -> args ( 'tplBase' ) ? $ this -> request -> args ( 'tplBase' ) : dirname ( $ tpl ) ; $ content = file_get_contents ( $ tpl ) ; $ this -> prepareTpl ( $ content ) ; return json_decode ( $ content , true ) ; }
Load the JSON extract tpl data into a PHP array .
19,696
protected function prepareTpl ( & $ content ) { $ this -> modx -> loadClass ( 'modParser' , '' , false , true ) ; $ parser = new Parser ( $ this -> modx ) ; $ this -> modx -> toPlaceholders ( $ this -> profile ) ; $ this -> modx -> toPlaceholders ( $ this -> request -> args ( ) ) ; $ parser -> processElementTags ( '' ,...
Parse the tpl replacing placeholders from the profile and request arguments .
19,697
protected function createPackage ( $ name , $ version , $ release = '' ) { $ this -> modx -> loadClass ( 'transport.xPDOTransport' , XPDO_CORE_PATH , true , true ) ; $ this -> modx -> loadClass ( 'transport.xPDOVehicle' , XPDO_CORE_PATH , true , true ) ; $ this -> modx -> loadClass ( 'transport.xPDOObjectVehicle' , XPD...
Create a Transport package to store extracted data into .
19,698
protected function getSequence ( ) { return $ this -> getRequest ( ) -> args ( 'version' ) || $ this -> getRequest ( ) -> args ( 'release' ) ? ( $ this -> getRequest ( ) -> args ( 'release' ) === null ? '' : $ this -> getRequest ( ) -> args ( 'release' ) ) : $ this -> modx -> version [ 'full_version' ] ; }
Get a package sequence for this snapshot .
19,699
function message ( $ phone_number , $ message , $ message_type , array $ other = [ ] ) { return $ this -> post ( self :: MESSAGING_RESOURCE , array_merge ( $ other , [ "phone_number" => $ phone_number , "message" => $ message , "message_type" => $ message_type ] ) ) ; }
Send a message to the target phone_number .