idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
56,200
protected function isSpecialLine ( $ line ) { if ( strlen ( $ line ) < 3 ) { return false ; } $ letter = $ line [ 0 ] ; $ environment = $ this -> environment ; if ( ! in_array ( $ letter , $ environment :: $ letters ) ) { return false ; } for ( $ i = 1 ; $ i < strlen ( $ line ) ; $ i ++ ) { if ( $ line [ $ i ] != $ letter ) { return false ; } } return $ letter ; }
Tell if a line is a special separating line for title and separators returns the depth of the special line
56,201
protected function findTableChars ( $ line ) { $ lineChar = $ line [ 0 ] ; $ spaceChar = null ; for ( $ i = 0 ; $ i < strlen ( $ line ) ; $ i ++ ) { if ( $ line [ $ i ] != $ lineChar ) { if ( $ spaceChar == null ) { $ spaceChar = $ line [ $ i ] ; } else { if ( $ line [ $ i ] != $ spaceChar ) { return false ; } } } } return array ( $ lineChar , $ spaceChar ) ; }
Finding the table chars
56,202
protected function parseTableLine ( $ line ) { $ header = false ; $ pretty = false ; $ line = trim ( $ line ) ; if ( ! strlen ( $ line ) ) { return false ; } $ chars = $ this -> findTableChars ( $ line ) ; if ( ! $ chars ) { return false ; } if ( $ chars [ 0 ] == Environment :: $ prettyTableJoint && $ chars [ 1 ] == Environment :: $ prettyTableLetter ) { $ pretty = true ; $ chars = array ( Environment :: $ prettyTableLetter , Environment :: $ prettyTableJoint ) ; } else if ( $ chars [ 0 ] == Environment :: $ prettyTableJoint && $ chars [ 1 ] == Environment :: $ prettyTableHeader ) { $ pretty = true ; $ header = true ; $ chars = array ( Environment :: $ prettyTableHeader , Environment :: $ prettyTableJoint ) ; } else { if ( ! ( $ chars [ 0 ] == Environment :: $ tableLetter && $ chars [ 1 ] == ' ' ) ) { return false ; } } $ parts = array ( ) ; $ separator = false ; for ( $ i = 0 ; $ i < strlen ( $ line ) ; $ i ++ ) { if ( $ line [ $ i ] == $ chars [ 0 ] ) { if ( ! $ separator ) { $ parts [ ] = $ i ; $ separator = true ; } } else { if ( $ line [ $ i ] == $ chars [ 1 ] ) { $ separator = false ; } else { return false ; } } } if ( count ( $ parts ) > 1 ) { return array ( $ header , $ pretty , $ parts ) ; } return false ; }
If the given line is a table line this will returns the parts of the given line i . e the offset of the separators
56,203
protected function parseListLine ( $ line ) { $ depth = 0 ; for ( $ i = 0 ; $ i < strlen ( $ line ) ; $ i ++ ) { $ char = $ line [ $ i ] ; if ( $ char == ' ' ) { $ depth ++ ; } else if ( $ char == "\t" ) { $ depth += 2 ; } else { break ; } } if ( preg_match ( '/^((\*|\-)|([\d#]+)\.) (.+)$/' , trim ( $ line ) , $ match ) ) { return array ( 'prefix' => $ line [ $ i ] , 'ordered' => ( $ line [ $ i ] == '*' || $ line [ $ i ] == '-' ) ? false : true , 'depth' => $ depth , 'text' => array ( $ match [ 4 ] ) ) ; } return false ; }
Parses a list line
56,204
protected function isListLine ( $ line ) { $ listLine = $ this -> parseListLine ( $ line ) ; if ( $ listLine ) { return $ listLine [ 'depth' ] == 0 || ! $ this -> isCode ; } return false ; }
Is the given line a list line ?
56,205
public function pushListLine ( $ line , $ flush = false ) { if ( trim ( $ line ) ) { $ infos = $ this -> parseListLine ( $ line ) ; if ( $ infos ) { if ( $ this -> lineInfo ) { $ this -> lineInfo [ 'text' ] = $ this -> createSpan ( $ this -> lineInfo [ 'text' ] ) ; $ this -> buffer -> addLine ( $ this -> lineInfo ) ; } $ this -> lineInfo = $ infos ; } else { if ( $ this -> listFlow || $ line [ 0 ] == ' ' ) { $ this -> lineInfo [ 'text' ] [ ] = $ line ; } else { $ flush = true ; } } $ this -> listFlow = true ; } else { $ this -> listFlow = false ; } if ( $ flush ) { if ( $ this -> lineInfo ) { $ this -> lineInfo [ 'text' ] = $ this -> createSpan ( $ this -> lineInfo [ 'text' ] ) ; $ this -> buffer -> addLine ( $ this -> lineInfo ) ; $ this -> lineInfo = null ; } return false ; } return true ; }
Push a line to the current list node buffer
56,206
protected function initDirective ( $ line ) { if ( preg_match ( '/^\.\. (\|(.+)\| |)([^\s]+)::( (.*)|)$/mUsi' , $ line , $ match ) ) { $ this -> directive = array ( 'variable' => $ match [ 2 ] , 'name' => $ match [ 3 ] , 'data' => trim ( $ match [ 4 ] ) , 'options' => array ( ) ) ; return true ; } return false ; }
Get current directive if the buffer contains one
56,207
protected function directiveAddOption ( $ line ) { if ( preg_match ( '/^(\s+):(.+): (.*)$/mUsi' , $ line , $ match ) ) { $ this -> directive [ 'options' ] [ $ match [ 2 ] ] = trim ( $ match [ 3 ] ) ; return true ; } else if ( preg_match ( '/^(\s+):(.+):(\s*)$/mUsi' , $ line , $ match ) ) { $ value = trim ( $ match [ 3 ] ) ; $ this -> directive [ 'options' ] [ $ match [ 2 ] ] = true ; return true ; } else { return false ; } }
Try to add an option line to the current directive returns true if sucess and false if failure
56,208
protected function getCurrentDirective ( ) { if ( ! $ this -> directive ) { $ this -> getEnvironment ( ) -> getErrorManager ( ) -> error ( 'Asking for current directive, but there is not' ) ; } $ name = $ this -> directive [ 'name' ] ; if ( isset ( $ this -> directives [ $ name ] ) ) { return $ this -> directives [ $ name ] ; } else { $ message = 'Unknown directive: ' . $ name ; $ message .= ' in ' . $ this -> getFilename ( ) . ' line ' . $ this -> getCurrentLine ( ) ; $ this -> getEnvironment ( ) -> getErrorManager ( ) -> error ( $ message ) ; return null ; } }
Gets the current directive
56,209
protected function flush ( ) { $ node = null ; $ this -> isCode = false ; if ( $ this -> buffer ) { switch ( $ this -> state ) { case self :: STATE_TITLE : $ data = implode ( "\n" , $ this -> buffer ) ; $ level = $ this -> environment -> getLevel ( $ this -> specialLetter ) ; $ token = $ this -> environment -> createTitle ( $ level ) ; $ node = $ this -> kernel -> build ( 'Nodes\TitleNode' , $ this -> createSpan ( $ data ) , $ level , $ token ) ; break ; case self :: STATE_SEPARATOR : $ level = $ this -> environment -> getLevel ( $ this -> specialLetter ) ; $ node = $ this -> kernel -> build ( 'Nodes\SeparatorNode' , $ level ) ; break ; case self :: STATE_CODE : $ node = $ this -> kernel -> build ( 'Nodes\CodeNode' , $ this -> buffer ) ; break ; case self :: STATE_BLOCK : $ node = $ this -> kernel -> build ( 'Nodes\QuoteNode' , $ this -> buffer ) ; $ data = $ node -> getValue ( ) ; $ subParser = $ this -> getSubParser ( ) ; $ document = $ subParser -> parseLocal ( $ data ) ; $ node -> setValue ( $ document ) ; break ; case self :: STATE_LIST : $ this -> pushListLine ( null , true ) ; $ node = $ this -> buffer ; break ; case self :: STATE_TABLE : $ node = $ this -> buffer ; $ node -> finalize ( $ this ) ; break ; case self :: STATE_NORMAL : $ this -> isCode = $ this -> prepareCode ( ) ; $ node = $ this -> kernel -> build ( 'Nodes\ParagraphNode' , $ this -> createSpan ( $ this -> buffer ) ) ; break ; } } if ( $ this -> directive ) { $ currentDirective = $ this -> getCurrentDirective ( ) ; if ( $ currentDirective ) { $ currentDirective -> process ( $ this , $ node , $ this -> directive [ 'variable' ] , $ this -> directive [ 'data' ] , $ this -> directive [ 'options' ] ) ; } $ node = null ; } $ this -> directive = null ; if ( $ node ) { $ this -> document -> addNode ( $ node ) ; } $ this -> init ( ) ; }
Flushes the current buffer to create a node
56,210
public function includeFileAllowed ( $ path ) { if ( ! $ this -> includeAllowed ) { return false ; } if ( ! @ is_readable ( $ path ) ) { return false ; } if ( empty ( $ this -> includeRoot ) ) { return true ; } $ real = realpath ( $ path ) ; foreach ( explode ( ':' , $ this -> includeRoot ) as $ root ) { if ( strpos ( $ real , $ root ) === 0 ) { return true ; } } return false ; }
Is this file allowed to be included?
56,211
protected function parseLines ( $ document ) { $ document = str_replace ( "\r\n" , "\n" , $ document ) ; $ document = "\n$document\n" ; $ document = $ this -> includeFiles ( $ document ) ; $ bom = "\xef\xbb\xbf" ; $ document = str_replace ( $ bom , '' , $ document ) ; $ lines = explode ( "\n" , $ document ) ; $ this -> state = self :: STATE_BEGIN ; foreach ( $ lines as $ n => $ line ) { $ this -> currentLine = $ n ; while ( ! $ this -> parseLine ( $ line ) ) ; } $ this -> flush ( ) ; $ this -> flush ( ) ; }
Process all the lines of a document string
56,212
public function getTocs ( ) { $ tocs = array ( ) ; $ nodes = $ this -> getNodes ( function ( $ node ) { return $ node instanceof TocNode ; } ) ; foreach ( $ nodes as $ toc ) { $ files = $ toc -> getFiles ( ) ; foreach ( $ files as & $ file ) { $ file = $ this -> environment -> canonicalUrl ( $ file ) ; } $ tocs [ ] = $ files ; } return $ tocs ; }
Get the table of contents of the document
56,213
public function isHoliday ( $ iso , $ date = 'now' , $ state = null ) { return ( $ this -> getHoliday ( $ iso , $ date , $ state ) !== null ) ; }
Checks wether a given date is a holiday
56,214
public function getHoliday ( $ iso , $ date = 'now' , $ state = null ) { $ iso = $ this -> getIsoCode ( $ iso ) ; $ date = $ this -> getDateTime ( $ date ) ; $ provider = $ this -> getProvider ( $ iso ) ; $ holiday = $ provider -> getHolidayByDate ( $ date , $ state ) ; return $ holiday ; }
Provides detailed information about a specific holiday
56,215
public function pre_commit ( ) { if ( file_exists ( self :: MARKER_FILE ) ) { unlink ( self :: MARKER_FILE ) ; } $ hash = md5 ( file_get_contents ( 'README.md' ) ) ; shell_exec ( 'vendor/bin/wp scaffold package-readme . --force > /dev/null 2>&1' ) ; if ( $ hash === md5 ( file_get_contents ( 'README.md' ) ) ) { return ; } shell_exec ( 'touch ' . self :: MARKER_FILE ) ; }
Try to regenerate the README . md file and memorize whether changes were detected .
56,216
protected function orderHandler ( $ order_parameter ) { list ( $ order , $ seed ) = $ this -> getOrderAndSeed ( $ order_parameter ) ; $ this -> arguments [ 'order' ] = $ order ; $ this -> arguments [ 'seed' ] = $ seed ; }
Only called when order argument is used .
56,217
private function getOrderAndSeed ( $ order ) { @ list ( $ order , $ seed ) = explode ( ':' , $ order , 2 ) ; if ( empty ( $ seed ) ) { $ seed = $ this -> getRandomSeed ( ) ; } if ( ! is_numeric ( $ seed ) ) { $ this -> showError ( "Could not use '$seed' as seed." ) ; } return array ( $ order , $ seed ) ; }
Parses arguments to know if random order is desired and if seed was chosen .
56,218
protected function extractCompletions ( $ response ) { $ aggregations = isset ( $ response [ 'aggregations' ] ) ? $ response [ 'aggregations' ] : [ ] ; return array_map ( function ( $ option ) { return $ option [ 'key' ] ; } , $ aggregations [ 'autocomplete' ] [ 'buckets' ] ) ; }
Extract autocomplete options
56,219
protected function printFooter ( \ PHPUnit \ Framework \ TestResult $ result ) : void { parent :: printFooter ( $ result ) ; $ this -> writeNewLine ( ) ; $ this -> write ( "Randomized with seed: {$this->seed}" ) ; $ this -> writeNewLine ( ) ; }
Just add to the output the seed used to randomize the test suite .
56,220
private function randomizeSuiteThatContainsOtherSuites ( $ suite , $ seed ) { $ order = 0 ; foreach ( $ suite -> tests ( ) as $ test ) { if ( $ test instanceof \ PHPUnit \ Framework \ TestSuite && $ this -> testSuiteContainsOtherSuites ( $ test ) ) { $ this -> randomizeSuiteThatContainsOtherSuites ( $ test , $ seed ) ; } if ( $ test instanceof \ PHPUnit \ Framework \ TestSuite ) { $ this -> randomizeSuite ( $ test , $ seed , $ this -> order ) ; } $ this -> order ++ ; } return $ this -> randomizeSuite ( $ suite , $ seed , $ this -> order , false ) ; }
Randomize each Test Suite inside the main Test Suite .
56,221
private function randomizeSuite ( $ suite , $ seed , $ order = 0 , $ fix_depends = true ) { $ reflected = new \ ReflectionObject ( $ suite ) ; $ property = $ reflected -> getProperty ( 'tests' ) ; $ property -> setAccessible ( true ) ; $ property -> setValue ( $ suite , $ this -> randomizeTestsCases ( $ suite -> tests ( ) , $ seed , $ order , $ fix_depends ) ) ; return $ suite ; }
Randomize the test cases inside a TestSuite with the given seed .
56,222
private function setOrder ( $ tests_dependencies , $ tests_methods ) { $ new_order = [ ] ; foreach ( $ tests_methods as $ method_name => $ order ) { if ( isset ( $ tests_dependencies [ $ method_name ] ) && ! in_array ( $ tests_dependencies [ $ method_name ] , $ new_order ) ) { $ new_order [ ] = $ tests_dependencies [ $ method_name ] ; $ this -> isDependant ( $ new_order , $ tests_dependencies , $ tests_methods , $ tests_dependencies [ $ method_name ] ) ; } if ( ! in_array ( $ method_name , $ new_order ) ) { $ new_order [ ] = $ method_name ; } } return $ new_order ; }
preapare test methods required order
56,223
public function setId ( $ id ) { if ( ! ( is_string ( $ id ) and filter_var ( $ id , \ FILTER_VALIDATE_INT ) !== false ) and ! is_int ( $ id ) ) { throw new \ InvalidArgumentException ( "Integer ID expected." ) ; } $ this -> id = ( int ) trim ( $ id ) ; return $ this ; }
Sets the role ID .
56,224
public function intersect ( RolesStorageInterface $ roles ) { $ res = array_intersect ( $ roles -> getArrayCopy ( ) , $ this -> getArrayCopy ( ) ) ; return ( ! empty ( $ res ) ) ; }
Checks if the given RolesStorage has any intersections with this RolesStorage i . e . if the user has one of the roles stored in this object .
56,225
private function startServer ( ) { if ( $ this -> resource !== null ) { return ; } $ this -> writeln ( PHP_EOL ) ; $ this -> writeln ( 'Starting PhantomJS Server.' ) ; $ command = $ this -> getCommand ( ) ; if ( $ this -> config [ 'debug' ] ) { $ this -> writeln ( PHP_EOL ) ; $ this -> writeln ( 'Generated PhantomJS Command:' ) ; $ this -> writeln ( $ command ) ; $ this -> writeln ( PHP_EOL ) ; } $ descriptorSpec = [ [ 'pipe' , 'r' ] , [ 'file' , $ this -> getLogDir ( ) . 'phantomjs.output.txt' , 'w' ] , [ 'file' , $ this -> getLogDir ( ) . 'phantomjs.errors.txt' , 'a' ] , ] ; $ this -> resource = proc_open ( $ command , $ descriptorSpec , $ this -> pipes , null , null , [ 'bypass_shell' => true ] ) ; if ( ! is_resource ( $ this -> resource ) || ! proc_get_status ( $ this -> resource ) [ 'running' ] ) { proc_close ( $ this -> resource ) ; throw new ExtensionException ( $ this , 'Failed to start PhantomJS server.' ) ; } $ max_checks = 10 ; $ checks = 0 ; $ this -> write ( 'Waiting for the PhantomJS server to be reachable.' ) ; while ( true ) { if ( $ checks >= $ max_checks ) { throw new ExtensionException ( $ this , 'PhantomJS server never became reachable.' ) ; } $ fp = @ fsockopen ( '127.0.0.1' , $ this -> config [ 'port' ] , $ errCode , $ errStr , 10 ) ; if ( $ fp ) { $ this -> writeln ( '' ) ; $ this -> writeln ( 'PhantomJS server now accessible.' ) ; fclose ( $ fp ) ; break ; } $ this -> write ( '.' ) ; $ checks ++ ; sleep ( 1 ) ; } $ this -> writeln ( '' ) ; }
Start PhantomJS server .
56,226
private function stopServer ( ) { if ( $ this -> resource !== null ) { $ this -> write ( 'Stopping PhantomJS Server.' ) ; $ max_checks = 10 ; for ( $ i = 0 ; $ i < $ max_checks ; $ i ++ ) { if ( $ i === $ max_checks - 1 && proc_get_status ( $ this -> resource ) [ 'running' ] === true ) { $ this -> writeln ( '' ) ; $ this -> writeln ( 'Unable to properly shutdown PhantomJS server.' ) ; unset ( $ this -> resource ) ; break ; } if ( proc_get_status ( $ this -> resource ) [ 'running' ] === false ) { $ this -> writeln ( '' ) ; $ this -> writeln ( 'PhantomJS server stopped.' ) ; unset ( $ this -> resource ) ; break ; } foreach ( $ this -> pipes as $ pipe ) { if ( is_resource ( $ pipe ) ) { fclose ( $ pipe ) ; } } proc_terminate ( $ this -> resource , 2 ) ; $ this -> write ( '.' ) ; sleep ( 1 ) ; } } }
Stop PhantomJS server .
56,227
private function getCommandParameters ( ) { $ mapping = [ 'port' => '--webdriver' , 'proxy' => '--proxy' , 'proxyType' => '--proxy-type' , 'proxyAuth' => '--proxy-auth' , 'webSecurity' => '--web-security' , 'ignoreSslErrors' => '--ignore-ssl-errors' , 'sslProtocol' => '--ssl-protocol' , 'sslCertificatesPath' => '--ssl-certificates-path' , 'remoteDebuggerPort' => '--remote-debugger-port' , 'remoteDebuggerAutorun' => '--remote-debugger-autorun' , 'cookiesFile' => '--cookies-file' , 'diskCache' => '--disk-cache' , 'maxDiskCacheSize' => '--max-disk-cache-size' , 'loadImages' => '--load-images' , 'localStoragePath' => '--local-storage-path' , 'localStorageQuota' => '--local-storage-quota' , 'localToRemoteUrlAccess' => '--local-to-remote-url-access' , 'outputEncoding' => '--output-encoding' , 'scriptEncoding' => '--script-encoding' , 'webdriverLoglevel' => '--webdriver-loglevel' , 'webdriverLogfile' => '--webdriver-logfile' , ] ; $ params = [ ] ; foreach ( $ this -> config as $ configKey => $ configValue ) { if ( ! empty ( $ mapping [ $ configKey ] ) ) { if ( is_bool ( $ configValue ) ) { $ configValue = $ configValue ? 'true' : 'false' ; } $ params [ ] = $ mapping [ $ configKey ] . '=' . $ configValue ; } } return implode ( ' ' , $ params ) ; }
Build the parameters for our command .
56,228
private function getCommand ( ) { $ commandPrefix = $ this -> isWindows ( ) ? '' : 'exec ' ; return $ commandPrefix . escapeshellarg ( realpath ( $ this -> config [ 'path' ] ) ) . ' ' . $ this -> getCommandParameters ( ) ; }
Get PhantomJS command .
56,229
public function suiteInit ( SuiteEvent $ e ) { if ( isset ( $ this -> config [ 'suites' ] ) ) { if ( is_string ( $ this -> config [ 'suites' ] ) ) { $ suites = [ $ this -> config [ 'suites' ] ] ; } else { $ suites = $ this -> config [ 'suites' ] ; } if ( ! in_array ( $ e -> getSuite ( ) -> getBaseName ( ) , $ suites , true ) && ! in_array ( $ e -> getSuite ( ) -> getName ( ) , $ suites , true ) ) { return ; } } $ this -> startServer ( ) ; }
Suite Init .
56,230
public function handle ( Request $ request , Closure $ next , MediaTypeGuard $ guard = null ) { $ guard = $ guard ?? app ( MediaTypeGuard :: class ) ; if ( ! $ guard -> validateExistingContentType ( $ request ) || ! $ guard -> hasCorrectHeadersForData ( $ request ) ) { $ errors = ( new ErrorCollection ( ) ) -> add ( ErrorFactory :: buildUnsupportedMediaType ( ) ) ; $ encoder = Encoder :: instance ( [ ] , new EncoderOptions ( JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ) ; return new Response ( $ encoder -> encodeErrors ( $ errors ) , 415 , [ 'Content-Type' => $ guard -> getContentType ( ) ] ) ; } if ( ! $ guard -> hasCorrectlySetAcceptHeader ( $ request ) ) { $ errors = ( new ErrorCollection ( ) ) -> add ( ErrorFactory :: buildUnacceptable ( ) ) ; $ encoder = Encoder :: instance ( [ ] , new EncoderOptions ( JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ) ; return new Response ( $ encoder -> encodeErrors ( $ errors ) , 406 , [ 'Content-Type' => $ guard -> getContentType ( ) ] ) ; } $ response = $ next ( $ request ) ; $ response -> header ( 'Content-Type' , $ guard -> getContentType ( ) ) ; return $ response ; }
Adds support for the Server Responsibilities section of content negotiation spec for json - api .
56,231
public function addShould ( $ args ) { $ this -> boolQuery -> addShould ( $ args ) ; $ this -> query = new \ Elastica \ Query ( $ this -> boolQuery ) ; }
Add should part to query .
56,232
public static function displayFilename ( FtpFile $ file , FtpWidget $ context ) { if ( $ context -> allowNavigation && self :: isDir ( $ file ) ) { $ dir = $ context -> baseFolder . "/" . $ file -> filename ; if ( $ context -> baseFolder == "/" ) { $ dir = "/" . $ file -> filename ; } if ( $ file -> filename == '..' ) { $ dir = str_replace ( '\\' , '/' , dirname ( $ context -> baseFolder ) ) ; } $ arr = array_merge ( [ "" ] , $ _GET , [ $ context -> navKey => $ dir ] ) ; return \ yii \ helpers \ Html :: a ( $ file -> filename , $ arr ) ; } else { return $ file -> filename ; } }
Build filename for FtpWidget .
56,233
public function authorize ( string $ action , $ object , array $ source = null ) { if ( $ this -> request ( ) -> user ( ) -> cant ( $ action , $ object ) ) { throw new RequestFailedAuthorization ( new Error ( $ id = null , $ link = new Link ( 'https://tools.ietf.org/html/rfc7231#section-6.5.3' ) , $ status = '403' , $ code = null , $ title = 'Forbidden' , $ desc = 'Access is denied for one or more of the specified resources' , $ source , $ meta = null ) ) ; } return true ; }
Ensure that a requested operation is authorized . If not throw an exception .
56,234
public function prepareRequest ( $ method , array $ params = [ ] ) { $ request = [ 'jsonrpc' => '2.0' , 'method' => $ method , 'id' => mt_rand ( ) ] ; $ request [ 'params' ] = $ params ? $ params : [ ] ; return $ request ; }
prepare a json rpc request array
56,235
public function makeRequest ( $ request ) { $ optionsSet = curl_setopt_array ( $ this -> ch , [ CURLOPT_URL => $ this -> url , CURLOPT_HEADER => false , CURLOPT_RETURNTRANSFER => true , CURLOPT_CONNECTTIMEOUT => $ this -> timeout , CURLOPT_USERAGENT => 'JSON-RPC Random.org PHP Client' , CURLOPT_HTTPHEADER => $ this -> headers , CURLOPT_FOLLOWLOCATION => false , CURLOPT_CUSTOMREQUEST => 'POST' , CURLOPT_SSL_VERIFYPEER => $ this -> verifyPeer , CURLOPT_POSTFIELDS => json_encode ( $ request ) ] ) ; if ( ! $ optionsSet ) { throw new \ Exception ( 'Cannot set curl options' ) ; } $ responseBody = curl_exec ( $ this -> ch ) ; $ responseCode = curl_getinfo ( $ this -> ch , CURLINFO_HTTP_CODE ) ; if ( curl_errno ( $ this -> ch ) ) { throw new \ RuntimeException ( curl_error ( $ this -> ch ) ) ; } if ( $ responseCode === 401 || $ responseCode === 403 ) { throw new \ RuntimeException ( 'Access denied' ) ; } $ response = json_decode ( $ responseBody , true ) ; if ( $ this -> debug ) { echo ( '==> Request: ' . PHP_EOL . json_encode ( $ request , JSON_PRETTY_PRINT ) ) ; echo ( '==> Response: ' . PHP_EOL . json_encode ( $ response , JSON_PRETTY_PRINT ) ) ; } return $ response ; }
make the request to the server and get response
56,236
public function getResponse ( array $ response ) { if ( isset ( $ response [ 'error' ] [ 'code' ] ) ) { $ this -> handleRpcErrors ( $ response [ 'error' ] ) ; } return isset ( $ response [ 'result' ] ) ? $ response [ 'result' ] : null ; }
Get the response from the server if there are API error pass them to error handler function
56,237
public function handleRpcErrors ( $ error ) { switch ( $ error [ 'code' ] ) { case - 32600 : throw new \ InvalidArgumentException ( 'Invalid Request: ' . $ error [ 'message' ] ) ; case - 32601 : throw new \ BadFunctionCallException ( 'Procedure not found: ' . $ error [ 'message' ] ) ; case - 32602 : throw new \ InvalidArgumentException ( 'Invalid arguments: ' . $ error [ 'message' ] ) ; case - 32603 : throw new \ RuntimeException ( 'Internal Error: ' . $ error [ 'message' ] ) ; default : throw new \ RuntimeException ( 'Invalid request/response: ' . $ error [ 'message' ] , $ error [ 'code' ] ) ; } }
Process JSON - RPC errors
56,238
public function setHost ( $ host ) { if ( $ this -> host !== $ host ) { $ this -> close ( ) ; $ this -> host = $ host ; } }
Changing FTP host name or IP
56,239
public function setPort ( $ port ) { if ( $ this -> port !== $ port ) { $ this -> close ( ) ; $ this -> port = $ port ; } }
Changing FTP port .
56,240
public function setUser ( $ user ) { if ( $ this -> user !== $ user ) { $ this -> close ( ) ; $ this -> user = $ user ; } }
Changing FTP connecting username .
56,241
public function setPass ( $ pass ) { if ( $ this -> pass !== $ pass ) { $ this -> close ( ) ; $ this -> pass = $ pass ; } }
Changing FTP password .
56,242
public function setPassive ( $ passive ) { if ( $ this -> passive !== $ passive ) { $ this -> passive = $ passive ; if ( isset ( $ this -> handle ) && $ this -> handle != null ) { $ this -> pasv ( $ this -> passive ) ; } } }
Changing FTP passive mode .
56,243
public function systype ( ) { $ this -> connectIfNeeded ( ) ; $ res = @ ftp_systype ( $ this -> handle ) ; return $ res == null || $ res == false ? 'UNIX' : $ res ; }
Returns the remote system type .
56,244
public function pasv ( $ pasv ) { $ this -> connectIfNeeded ( ) ; $ this -> param = $ pasv ; if ( ! ftp_pasv ( $ this -> handle , $ pasv === true ) ) { throw new FtpException ( Yii :: t ( 'gftp' , 'Could not {set} passive mode on server "{host}": {message}' , [ 'host' => $ this -> host , 'set' => $ pasv ? "set" : "unset" ] ) ) ; } }
Turns on or off passive mode .
56,245
public function execute ( $ command , $ raw = false ) { $ this -> connectIfNeeded ( ) ; $ this -> param = $ command ; if ( ! $ raw && $ this -> stringStarts ( $ command , "SITE EXEC" ) ) { $ this -> exec ( substr ( $ command , strlen ( "SITE EXEC" ) ) ) ; return true ; } else if ( ! $ raw && $ this -> stringStarts ( $ command , "SITE" ) ) { $ this -> site ( substr ( $ command , strlen ( "SITE" ) ) ) ; return true ; } else { return $ this -> raw ( $ command ) ; } }
Execute any command on FTP server .
56,246
public function exec ( $ command ) { $ this -> connectIfNeeded ( ) ; $ this -> param = "SITE EXEC " . $ command ; $ exec = true ; if ( ! ftp_exec ( $ this -> handle , substr ( $ command , strlen ( "SITE EXEC" ) ) ) ) { throw new FtpException ( Yii :: t ( 'gftp' , 'Could not execute command "{command}" on "{host}"' , [ 'host' => $ this -> host , '{command}' => $ this -> param ] ) ) ; } }
Sends a SITE EXEC command request to the FTP server .
56,247
public function site ( $ command ) { $ this -> connectIfNeeded ( ) ; $ this -> param = "SITE " . $ command ; if ( ! ftp_site ( $ this -> handle , $ command ) ) { throw new FtpException ( Yii :: t ( 'gftp' , 'Could not execute command "{command}" on "{host}"' , [ 'host' => $ this -> host , '{command}' => $ this -> param ] ) ) ; } }
Sends a SITE command request to the FTP server .
56,248
public function raw ( $ command ) { $ this -> connectIfNeeded ( ) ; $ this -> param = $ command ; $ res = ftp_raw ( $ this -> handle , $ command ) ; return $ res ; }
Sends an arbitrary command to the FTP server .
56,249
public function isSmart ( AdminInterface $ admin , array $ values = [ ] ) { $ logicalControllerName = $ admin -> getRequest ( ) -> attributes -> get ( '_controller' ) ; $ currentAction = explode ( ':' , $ logicalControllerName ) ; $ currentAction = substr ( end ( $ currentAction ) , 0 , - \ strlen ( 'Action' ) ) ; if ( ! \ in_array ( $ currentAction , $ this -> finderProvider -> getActionsByAdmin ( $ admin ) , true ) ) { return false ; } $ finderId = $ this -> finderProvider -> getFinderIdByAdmin ( $ admin ) ; list ( $ indexName , $ typeName ) = \ array_slice ( explode ( '.' , $ finderId ) , 2 ) ; $ typeConfiguration = $ this -> configManager -> getTypeConfiguration ( $ indexName , $ typeName ) ; $ mapping = $ typeConfiguration -> getMapping ( ) ; $ mappedFieldNames = array_keys ( $ mapping [ 'properties' ] ) ; $ smart = true ; foreach ( $ values as $ key => $ value ) { if ( ! \ is_array ( $ value ) || ! isset ( $ value [ 'value' ] ) ) { continue ; } if ( ! $ value [ 'value' ] ) { continue ; } if ( ! \ in_array ( $ key , $ mappedFieldNames , true ) ) { $ ret = $ admin -> getModelManager ( ) -> getParentMetadataForProperty ( $ admin -> getClass ( ) , $ key , $ admin -> getModelManager ( ) ) ; list ( $ metadata , $ propertyName , $ parentAssociationMappings ) = $ ret ; if ( ! $ metadata -> hasField ( $ key ) ) { break ; } $ smart = false ; break ; } } return $ smart ; }
Returns true if this datagrid builder can process these values .
56,250
public function setConnectionString ( $ connectionString ) { if ( ! isset ( $ connectionString ) || ! is_string ( $ connectionString ) || trim ( $ connectionString ) === "" ) { throw new FtpException ( Yii :: t ( 'gftp' , '{connectString} is not a valid connection string' , [ 'connectString' => $ connectionString ] ) ) ; } $ this -> close ( ) ; $ this -> connectionString = $ connectionString ; }
Sets a new connection string . If connection is already openned try to close it before .
56,251
public function connect ( ) { if ( isset ( $ this -> handle ) && $ this -> handle != null ) { $ this -> close ( ) ; } $ this -> parseConnectionString ( ) ; $ this -> handle = \ Yii :: createObject ( $ this -> driverOptions ) ; $ this -> handle -> connect ( ) ; $ this -> onConnectionOpen ( new Event ( [ 'sender' => $ this ] ) ) ; }
Connect to FTP server .
56,252
public function login ( ) { $ this -> connectIfNeeded ( false ) ; $ this -> handle -> login ( ) ; $ this -> onLogin ( new Event ( [ 'sender' => $ this , 'data' => $ this -> handle -> user ] ) ) ; }
Log into the FTP server . If connection is not openned it will be openned before login .
56,253
public function ls ( $ dir = "." , $ full = false , $ recursive = false ) { $ this -> connectIfNeeded ( ) ; return $ this -> handle -> ls ( $ dir , $ full , $ recursive ) ; }
Returns list of files in the given directory .
56,254
public function close ( ) { if ( isset ( $ this -> handle ) && $ this -> handle != null ) { $ this -> handle -> close ( ) ; $ this -> handle = false ; $ this -> onConnectionClose ( new Event ( [ 'sender' => $ this ] ) ) ; } }
Close FTP connection .
56,255
public function mkdir ( $ dir ) { $ this -> connectIfNeeded ( ) ; $ this -> handle -> mkdir ( $ dir ) ; $ this -> onFolderCreated ( new Event ( [ 'sender' => $ this , 'data' => $ dir ] ) ) ; }
Create a new folder on FTP server .
56,256
public function rmdir ( $ dir ) { $ this -> connectIfNeeded ( ) ; $ this -> handle -> rmdir ( $ dir ) ; $ this -> onFolderDeleted ( new Event ( [ 'sender' => $ this , 'data' => $ dir ] ) ) ; }
Removes a folder on FTP server .
56,257
public function chdir ( $ dir ) { $ this -> connectIfNeeded ( ) ; $ this -> handle -> chdir ( $ dir ) ; $ this -> onFolderChanged ( new Event ( [ 'sender' => $ this , 'data' => $ dir ] ) ) ; try { $ cwd = $ this -> pwd ( ) ; } catch ( FtpException $ ex ) { $ cwd = $ dir ; } return $ cwd ; }
Changes current folder .
56,258
public function get ( $ remote_file , $ local_file = null , $ mode = FTP_ASCII , $ asynchronous = false , callable $ asyncFn = null ) { $ this -> connectIfNeeded ( ) ; $ local_file = $ this -> handle -> get ( $ remote_file , $ local_file , $ mode , $ asynchronous , $ asyncFn ) ; $ this -> onFileDownloaded ( new Event ( [ 'sender' => $ this , 'data' => $ local_file ] ) ) ; return $ local_file ; }
Download a file from FTP server .
56,259
public function put ( $ local_file , $ remote_file = null , $ mode = FTP_ASCII , $ asynchronous = false , callable $ asyncFn = null ) { $ this -> connectIfNeeded ( ) ; $ full_remote_file = $ this -> handle -> put ( $ local_file , $ remote_file , $ mode , $ asynchronous , $ asyncFn ) ; $ this -> onFileUploaded ( new Event ( [ 'sender' => $ this , 'data' => $ remote_file ] ) ) ; return $ full_remote_file ; }
Upload a file to the FTP server .
56,260
public function delete ( $ path ) { $ this -> connectIfNeeded ( ) ; $ this -> handle -> delete ( $ path ) ; $ this -> onFileDeleted ( new Event ( [ 'sender' => $ this , 'data' => $ path ] ) ) ; }
Deletes specified files from FTP server .
56,261
public function chmod ( $ mode , $ file ) { $ this -> connectIfNeeded ( ) ; $ this -> handle -> chmod ( $ mode , $ file ) ; $ this -> onFileModeChanged ( new Event ( [ 'sender' => $ this , 'data' => [ 'mode' => $ mode , 'file' => $ file ] ] ) ) ; }
Set permissions on a file via FTP .
56,262
protected function cleanup ( array & $ data ) { foreach ( $ data as & $ value ) { if ( \ is_array ( $ value ) ) { $ this -> cleanup ( $ value ) ; } } $ data = array_filter ( $ data , function ( $ value ) { return null !== $ value ; } ) ; }
Recursively filter an array removing null and empty string values .
56,263
protected function decodeCustomFields ( & $ decoded ) { foreach ( $ decoded [ '$xmlns' ] as $ prefix => $ namespace ) { if ( ! isset ( $ decoded [ 'entries' ] ) ) { $ this -> decodeObject ( $ prefix , $ namespace , $ decoded ) ; continue ; } foreach ( $ decoded [ 'entries' ] as & $ entry ) { $ this -> decodeObject ( $ prefix , $ namespace , $ entry ) ; } } }
Decode custom fields into a format usable by a normalizer .
56,264
protected function decodeObject ( $ prefix , $ namespace , & $ object ) { $ customFields = [ 'namespace' => $ namespace ] ; foreach ( $ object as $ key => $ value ) { if ( false !== strpos ( $ key , $ prefix . '$' ) ) { $ fieldName = substr ( $ key , \ strlen ( $ prefix ) + 1 ) ; $ customFields [ 'data' ] [ $ fieldName ] = $ value ; } } if ( ! empty ( $ customFields [ 'data' ] ) ) { $ object [ 'customFields' ] [ $ namespace ] = $ customFields ; } }
Decodes an object s custom fields .
56,265
private function setTcpdfConstants ( ) { foreach ( $ this -> config_constant_map as $ const => $ configkey ) { if ( ! defined ( $ const ) ) { if ( is_string ( \ Config :: get ( 'laravel-tcpdf::' . $ configkey ) ) ) { if ( strlen ( \ Config :: get ( 'laravel-tcpdf::' . $ configkey ) ) > 0 ) { define ( $ const , \ Config :: get ( 'laravel-tcpdf::' . $ configkey ) ) ; } } else { define ( $ const , \ Config :: get ( 'laravel-tcpdf::' . $ configkey ) ) ; } } } }
Set TCPDF constants based on configuration file . !Notice! Some contants are never used by TCPDF . They are in the config file of TCPDF but ... This is a bug by TCPDF but we set it for completeness .
56,266
public static function create ( RequestInterface $ request , ResponseInterface $ response , \ Exception $ previous = null , array $ ctx = [ ] ) { $ data = \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) , true ) ; MpxExceptionTrait :: validateData ( $ data ) ; $ altered = $ response -> withStatus ( $ data [ 'responseCode' ] , $ data [ 'title' ] ) ; return self :: createException ( $ request , $ altered , $ previous , $ ctx ) ; }
Create a new MPX API exception .
56,267
private static function createException ( RequestInterface $ request , ResponseInterface $ altered , \ Exception $ previous = null , array $ ctx = [ ] ) { if ( $ altered -> getStatusCode ( ) >= 400 && $ altered -> getStatusCode ( ) < 500 ) { return new ClientException ( $ request , $ altered , $ previous , $ ctx ) ; } return new ServerException ( $ request , $ altered , $ previous , $ ctx ) ; }
Create a client or server exception .
56,268
public function getCustomField ( string $ name , string $ objectType , string $ namespace ) : DiscoveredCustomField { $ services = $ this -> discovery -> getCustomFields ( ) ; if ( isset ( $ services [ $ name ] [ $ objectType ] [ $ namespace ] ) ) { return $ services [ $ name ] [ $ objectType ] [ $ namespace ] ; } throw new \ RuntimeException ( 'Custom field not found.' ) ; }
Returns one custom field .
56,269
private function addProperty ( ClassType $ class , Field $ field ) { $ property = $ class -> addProperty ( $ field -> getFieldName ( ) ) ; $ property -> setVisibility ( 'protected' ) ; if ( ! empty ( $ field -> getDescription ( ) ) ) { $ property -> setComment ( $ field -> getDescription ( ) ) ; $ property -> addComment ( '' ) ; } $ dataType = $ this -> getPhpDataType ( $ field ) ; $ property -> addComment ( '@var ' . $ dataType ) ; if ( $ this -> isCollectionType ( $ dataType ) ) { $ property -> setValue ( [ ] ) ; } }
Add a property to a class .
56,270
private function getPhpDataType ( Field $ field ) : string { $ dataType = static :: TYPE_MAP [ $ field -> getDataType ( ) ] ; if ( 'Single' != $ field -> getDataStructure ( ) ) { $ dataType .= '[]' ; } return $ dataType ; }
Get the PHP data type for a field including mapping to arrays .
56,271
public function getTargetAvailableDate ( ) : \ Lullabot \ Mpx \ DataService \ DateTime \ DateTimeFormatInterface { if ( ! $ this -> targetAvailableDate ) { return new NullDateTime ( ) ; } return $ this -> targetAvailableDate ; }
Returns the DateTime when this playback availability window begins .
56,272
public function setTargetAvailableDate ( \ Lullabot \ Mpx \ DataService \ DateTime \ DateTimeFormatInterface $ targetAvailableDate ) { $ this -> targetAvailableDate = $ targetAvailableDate ; }
Set the DateTime when this playback availability window begins .
56,273
public function getTargetExpirationDate ( ) : \ Lullabot \ Mpx \ DataService \ DateTime \ DateTimeFormatInterface { if ( ! $ this -> targetExpirationDate ) { return new NullDateTime ( ) ; } return $ this -> targetExpirationDate ; }
Returns the DateTime when this playback availability window ends .
56,274
public function setTargetExpirationDate ( \ Lullabot \ Mpx \ DataService \ DateTime \ DateTimeFormatInterface $ targetExpirationDate ) { $ this -> targetExpirationDate = $ targetExpirationDate ; }
Set the DateTime when this playback availability window ends .
56,275
private function getNewRequest ( string $ method , UriInterface $ uri ) : RequestInterface { return $ this -> transport -> createRequest ( $ method , $ uri ) ; }
To get a new PSR7 request from transport instance to be able to dialog with Sellsy API .
56,276
private function encodeOAuthHeaders ( & $ oauth ) { $ values = [ ] ; foreach ( $ oauth as $ key => & $ value ) { $ values [ ] = $ key . '="' . \ rawurlencode ( $ value ) . '"' ; } return 'OAuth ' . \ implode ( ', ' , $ values ) ; }
Transform an the OAuth array configuration to HTTP headers OAuth string .
56,277
private function setOAuthHeaders ( RequestInterface $ request ) : RequestInterface { $ now = new \ DateTime ( ) ; if ( $ this -> now instanceof \ DateTime ) { $ now = clone $ this -> now ; } $ encodedKey = \ rawurlencode ( $ this -> oauthConsumerSecret ) . '&' . \ rawurlencode ( $ this -> oauthAccessTokenSecret ) ; $ oauthParams = [ 'oauth_consumer_key' => $ this -> oauthConsumerKey , 'oauth_token' => $ this -> oauthAccessToken , 'oauth_nonce' => \ sha1 ( \ microtime ( true ) . \ rand ( 10000 , 99999 ) ) , 'oauth_timestamp' => $ now -> getTimestamp ( ) , 'oauth_signature_method' => 'PLAINTEXT' , 'oauth_version' => '1.0' , 'oauth_signature' => $ encodedKey , ] ; $ request = $ request -> withHeader ( 'Authorization' , $ this -> encodeOAuthHeaders ( $ oauthParams ) ) ; return $ request -> withHeader ( 'Expect' , '' ) ; }
Internal method to generate HTTP headers to use for the API authentication with OAuth protocol .
56,278
private function getUri ( ) : UriInterface { $ uri = $ this -> getNewUri ( ) ; if ( ! empty ( $ this -> apiUrl [ 'scheme' ] ) ) { $ uri = $ uri -> withScheme ( $ this -> apiUrl [ 'scheme' ] ) ; } if ( ! empty ( $ this -> apiUrl [ 'host' ] ) ) { $ uri = $ uri -> withHost ( $ this -> apiUrl [ 'host' ] ) ; } if ( ! empty ( $ this -> apiUrl [ 'port' ] ) ) { $ uri = $ uri -> withPort ( $ this -> apiUrl [ 'port' ] ) ; } if ( ! empty ( $ this -> apiUrl [ 'path' ] ) ) { $ uri = $ uri -> withPath ( $ this -> apiUrl [ 'path' ] ) ; } if ( ! empty ( $ this -> apiUrl [ 'query' ] ) ) { $ uri = $ uri -> withQuery ( $ this -> apiUrl [ 'query' ] ) ; } if ( ! empty ( $ this -> apiUrl [ 'fragment' ] ) ) { $ uri = $ uri -> withFragment ( $ this -> apiUrl [ 'fragment' ] ) ; } return $ uri ; }
To get the PSR7 Uri instance to configure the PSR7 request to be able to dialog with the Sellsy API .
56,279
private function setBodyRequest ( RequestInterface $ request , array & $ requestSettings ) : RequestInterface { $ multipartBody = [ ] ; foreach ( $ requestSettings as $ key => & $ value ) { $ multipartBody [ ] = [ 'name' => $ key , 'contents' => $ value ] ; } return $ request -> withBody ( $ this -> transport -> createStream ( $ multipartBody ) ) ; }
To register method s argument in the request for the Sellsy API .
56,280
private function getSellsyInstance ( ) : Sellsy { $ sellSy = new Sellsy ( '' , '' , '' , '' , '' ) ; $ transport = new class implements TransportInterface { public function createUri ( ) : UriInterface { } public function createRequest ( string $ method , UriInterface $ uri ) : RequestInterface { } public function createStream ( array & $ elements ) : StreamInterface { } public function execute ( RequestInterface $ request ) : ResponseInterface { } } ; $ sellSy -> setTransport ( $ transport ) ; $ sellSy -> AccountDatas ( ) ; $ sellSy -> TimeTracking ( ) ; return $ sellSy ; }
To return a instance of sellsy to check if a collection and a method is defined and is available here .
56,281
private function customFieldInstance ( $ prefix ) : array { $ ns = $ this -> xmlns [ $ prefix ] ; if ( ! $ discoveredCustomField = $ this -> customFields [ $ ns ] ) { throw new LogicException ( sprintf ( 'No custom field class was found for %s. setCustomFields() must be called before using this extractor.' , $ ns ) ) ; } return [ new Type ( 'object' , false , $ discoveredCustomField -> getClass ( ) ) ] ; }
Return the type for a custom field class .
56,282
private function customFieldsArrayType ( ) : array { $ collectionKeyType = new Type ( Type :: BUILTIN_TYPE_STRING ) ; $ collectionValueType = new Type ( 'object' , false , CustomFieldInterface :: class ) ; return [ new Type ( Type :: BUILTIN_TYPE_ARRAY , false , null , true , $ collectionKeyType , $ collectionValueType ) ] ; }
Return the type for an array of custom fields indexed by a string .
56,283
private function entriesType ( ) : array { if ( ! isset ( $ this -> class ) ) { throw new \ UnexpectedValueException ( 'setClass() must be called before using this extractor.' ) ; } $ collectionKeyType = new Type ( Type :: BUILTIN_TYPE_INT ) ; $ collectionValueType = new Type ( 'object' , false , $ this -> class ) ; return [ new Type ( Type :: BUILTIN_TYPE_ARRAY , false , null , true , $ collectionKeyType , $ collectionValueType ) ] ; }
Return the type of an array of entries used in an object list .
56,284
public function getAdded ( ) : \ Lullabot \ Mpx \ DataService \ DateTime \ DateTimeFormatInterface { if ( ! $ this -> added ) { return new NullDateTime ( ) ; } return $ this -> added ; }
Returns the date and time that this object was created .
56,285
public function setAdded ( \ Lullabot \ Mpx \ DataService \ DateTime \ DateTimeFormatInterface $ added ) { $ this -> added = $ added ; }
Set the date and time that this object was created .
56,286
public function getAddedByUserId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> addedByUserId ) { return new Uri ( ) ; } return $ this -> addedByUserId ; }
Returns the id of the user that created this object .
56,287
public function getId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> id ) { return new Uri ( ) ; } return $ this -> id ; }
Returns the globally unique URI of this object .
56,288
public function getMediaId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> mediaId ) { return new Uri ( ) ; } return $ this -> mediaId ; }
Returns the id of the Media object this object is associated with .
56,289
public function getOwnerId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> ownerId ) { return new Uri ( ) ; } return $ this -> ownerId ; }
Returns the id of the account that owns this object .
56,290
public function getServerId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> serverId ) { return new Uri ( ) ; } return $ this -> serverId ; }
Returns the id of the Server object representing the storage server that this file is on .
56,291
public function getSourceMediaFileId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> sourceMediaFileId ) { return new Uri ( ) ; } return $ this -> sourceMediaFileId ; }
Returns the id of the source MediaFile object that this file was generated from .
56,292
public function getTransformId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> transformId ) { return new Uri ( ) ; } return $ this -> transformId ; }
Returns the id of the encoding template used to generate the file .
56,293
public function getUpdated ( ) : \ Lullabot \ Mpx \ DataService \ DateTime \ DateTimeFormatInterface { if ( ! $ this -> updated ) { return new NullDateTime ( ) ; } return $ this -> updated ; }
Returns the date and time this object was last modified .
56,294
public function setUpdated ( \ Lullabot \ Mpx \ DataService \ DateTime \ DateTimeFormatInterface $ updated ) { $ this -> updated = $ updated ; }
Set the date and time this object was last modified .
56,295
public function getUpdatedByUserId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> updatedByUserId ) { return new Uri ( ) ; } return $ this -> updatedByUserId ; }
Returns the id of the user that last modified this object .
56,296
public static function getDefaultConfiguration ( $ handler = null ) { $ config = [ 'headers' => [ 'Accept' => 'application/json' , 'Content-Type' => 'application/json' , ] , ] ; if ( ! $ handler ) { $ handler = HandlerStack :: create ( ) ; $ handler -> push ( Middleware :: mpxErrors ( ) , 'mpx_errors' ) ; } $ config [ 'handler' ] = $ handler ; return $ config ; }
Get the default Guzzle client configuration array .
56,297
protected function handleXmlResponse ( ResponseInterface $ response , $ url ) { if ( false !== strpos ( ( string ) $ response -> getBody ( ) , 'xmlns:e="http://xml.theplatform.com/exception"' ) ) { if ( preg_match ( '~<e:title>(.+)</e:title><e:description>(.+)</e:description><e:responseCode>(.+)</e:responseCode>~' , ( string ) $ response -> getBody ( ) , $ matches ) ) { throw new ApiException ( "Error {$matches[1]} on request to {$url}: {$matches[2]}" , ( int ) $ matches [ 3 ] ) ; } elseif ( preg_match ( '~<title>(.+)</title><summary>(.+)</summary><e:responseCode>(.+)</e:responseCode>~' , ( string ) $ response -> getBody ( ) , $ matches ) ) { throw new ApiException ( "Error {$matches[1]} on request to {$url}: {$matches[2]}" , ( int ) $ matches [ 3 ] ) ; } } $ data = simplexml_load_string ( $ response -> getBody ( ) -> getContents ( ) ) ; $ data = [ $ data -> getName ( ) => static :: convertXmlToArray ( $ data ) ] ; return $ data ; }
Handle an XML API response .
56,298
protected static function convertXmlToArray ( \ SimpleXMLElement $ data ) { $ result = [ ] ; foreach ( ( array ) $ data as $ index => $ node ) { $ result [ $ index ] = ( \ is_object ( $ node ) ) ? static :: convertXmlToArray ( $ node ) : trim ( ( string ) $ node ) ; } return $ result ; }
Convert a string of XML to an associative array .
56,299
public function getUrl ( string $ service , bool $ insecure = false ) : Uri { if ( ! isset ( $ this -> resolveDomainResponse [ $ service ] ) ) { throw new \ RuntimeException ( sprintf ( '%s service was not found.' , $ service ) ) ; } $ url = $ this -> resolveDomainResponse [ $ service ] ; if ( ! $ insecure ) { $ url = $ url -> withScheme ( 'https' ) ; } return $ url ; }
Get the URL for a given service .