idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
49,600
public function get ( $ command ) { return isset ( $ this -> _commands [ $ command ] ) ? $ this -> _commands [ $ command ] : null ; }
Get command callback
49,601
public function move ( $ directory ) { if ( false === is_string ( $ directory ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ directory ) ) , E_USER_ERROR ) ; } if ( false === is_dir ( $ directory ) ) { return trigger_error ( sprintf (...
Move the current directory to a new directory including its content
49,602
public function delete ( ) { if ( false !== $ this -> directory -> getExists ( ) ) { if ( rmdir ( $ this -> directory -> getBasepath ( ) ) ) { $ this -> refresh ( ) ; } } return $ this ; }
Delete the current directory
49,603
public function copy ( $ directory ) { if ( false === is_dir ( $ directory ) ) { return trigger_error ( sprintf ( 'Directory "%s" passed to %s is not an existing directory' , $ directory , __METHOD__ ) , E_USER_ERROR ) ; } if ( false === is_writable ( $ directory ) ) { return trigger_error ( sprintf ( 'Directory "%s" p...
Copy the current directory contents to a new directory including its content
49,604
public function rename ( $ name ) { if ( false === is_string ( $ name ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ name ) ) , E_USER_ERROR ) ; } if ( false !== $ this -> directory -> getExists ( ) ) { if ( rename ( $ this -> directo...
Rename the current directory
49,605
public function getContent ( $ type = 'default' ) { if ( false === is_string ( $ type ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ type ) ) , E_USER_ERROR ) ; } if ( false === is_dir ( $ this -> directory -> getPath ( ) ) ) { return...
Returns files and folders about the current directory
49,606
public function chmod ( $ type ) { if ( false !== $ this -> directory -> getExists ( ) ) { return chmod ( $ this -> directory -> getPath ( ) , $ type ) ; } return false ; }
Returns true if current directory has successfully changed file mode otherwise false
49,607
public function chown ( $ username ) { if ( false === is_string ( $ username ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ username ) ) , E_USER_ERROR ) ; } if ( false !== $ this -> directory -> getExists ( ) ) { return chown ( $ thi...
Returns true if current directory has successfully changed owner otherwise false
49,608
public function isReadable ( ) { if ( false !== $ this -> directory -> getExists ( ) ) { $ this -> refresh ( ) ; return $ this -> directory -> getReadable ( ) ; } return false ; }
Returns boolean if the current directory is readable
49,609
public function isWritable ( ) { if ( false !== $ this -> directory -> getExists ( ) ) { $ this -> refresh ( ) ; return $ this -> directory -> getWritable ( ) ; } return false ; }
Returns boolean if the current directory is writable
49,610
public function refresh ( ) { $ directory = new Directory ( $ this -> directory -> getPath ( ) ) ; $ this -> directory = $ directory -> entity ( ) ; return $ this ; }
Drop old and create new directory entity to update information about current directory
49,611
private function rcopy ( $ source , $ destination ) { if ( false === is_string ( $ source ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ source ) ) , E_USER_ERROR ) ; } if ( false === is_string ( $ destination ) ) { return trigger_err...
Copy all contens of directory to an existing directory
49,612
public function toArray ( $ set = [ ] , $ convert = true ) { $ methods = get_class_methods ( $ this ) ; $ array = [ ] ; if ( true === is_string ( $ set ) ) { $ set = [ $ set ] ; } $ set = array_flip ( $ set ) ; $ amount = count ( $ set ) ; foreach ( $ methods as $ method ) { $ chunks = explode ( 'get' , $ method ) ; if...
Converts all getters to an Array
49,613
public function now ( $ format = null ) { $ date = $ this -> currentDate ? clone $ this -> currentDate : ( $ this -> currentDate = new \ DateTime ( ) ) ; return empty ( $ format ) ? $ date : $ date -> format ( $ format ) ; }
return current date
49,614
public function cmdUpdateCurrency ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ this -> setSubmitted ( null , $ params ) ; $ this -> setSubmitted ( 'update' , $ params [ 0 ] ) ; $ this -> valida...
Callback for currency - update
49,615
public function cmdGetCurrency ( ) { $ list = $ this -> getListCurrency ( ) ; $ this -> outputFormat ( $ list ) ; $ this -> outputFormatTableCurrency ( $ list ) ; $ this -> output ( ) ; }
Callback for currency - get command
49,616
public function cmdDeleteCurrency ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( empty ( $ id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = false ; if ( ! empty ( $ id ) ) { $ result = $ this -> currency -> delete ( $ id ) ; ...
Callback for currency - delete command
49,617
protected function outputFormatTableCurrency ( array $ items ) { $ header = array ( $ this -> text ( 'Code' ) , $ this -> text ( 'Name' ) , $ this -> text ( 'Symbol' ) , $ this -> text ( 'Conversion rate' ) , $ this -> text ( 'In database' ) , $ this -> text ( 'Enabled' ) ) ; $ rows = array ( ) ; foreach ( $ items as $...
Output formatted table
49,618
protected function submitAddCurrency ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'currency' ) ; $ this -> addCurrency ( ) ; }
Add a currency at once
49,619
protected function wizardAddCurrency ( ) { $ this -> validatePrompt ( 'code' , $ this -> text ( 'Code' ) , 'currency' ) ; $ this -> validatePrompt ( 'name' , $ this -> text ( 'Name' ) , 'currency' ) ; $ this -> validatePrompt ( 'symbol' , $ this -> text ( 'Symbol' ) , 'currency' ) ; $ this -> validatePrompt ( 'major_un...
Adds a currency step by step
49,620
protected function init ( ) { $ handle = curl_init ( ) ; $ this -> handle = $ handle ; $ this -> setSerializer ( new DefaultSerializer ( ) ) ; $ this -> scheme = self :: SCHEME_PLAIN ; $ this -> httpOptions = array ( ) ; $ this -> httpOptions [ CURLOPT_RETURNTRANSFER ] = true ; $ this -> httpOptions [ CURLOPT_FOLLOWLOC...
initialize default values
49,621
protected function setHost ( $ host , $ port = null ) { $ this -> host = $ host ; if ( $ port !== null ) { if ( is_numeric ( $ port ) ) { $ this -> port = ( int ) $ port ; } else { throw new ConfigurationException ( "Port '{$port}' is not numeric" ) ; } } }
Sets hostname and optional port
49,622
public function performRequest ( $ method , $ uri , $ params = null , $ body = null ) { try { if ( $ body !== null ) { $ body = $ this -> getSerializer ( ) -> serialize ( $ body ) ; } return $ this -> processRequest ( $ method , $ uri , $ params , $ body ) ; } catch ( ClientErrorResponseException $ exception ) { throw ...
performs the request
49,623
public function get ( $ uri , $ params = null , $ body = null ) { return $ this -> performRequest ( "get" , $ uri , $ params , $ body ) ; }
perform a get request
49,624
public function put ( $ uri , $ params = null , $ body = null ) { return $ this -> performRequest ( "put" , $ uri , $ params , $ body ) ; }
perform a put request
49,625
public function post ( $ uri , $ params = null , $ body = null ) { return $ this -> performRequest ( "post" , $ uri , $ params , $ body ) ; }
perform a post request
49,626
public function patch ( $ uri , $ params = null , $ body = null ) { return $ this -> performRequest ( "patch" , $ uri , $ params , $ body ) ; }
perform a patch
49,627
public function head ( $ uri , $ params = null , $ body = null ) { return $ this -> performRequest ( "head" , $ uri , $ params , $ body ) ; }
perform a head request
49,628
public function delete ( $ uri , $ params = null , $ body = null ) { return $ this -> performRequest ( "delete" , $ uri , $ params , $ body ) ; }
perform a delete request
49,629
protected function processRequest ( $ method , $ uri , $ params = null , $ body = null ) { $ methodString = $ this -> getMethod ( $ method ) ; if ( method_exists ( $ this , $ methodString ) ) { return $ this -> $ methodString ( $ method , $ uri , $ params , $ body ) ; } else { throw new InvalidRequestMethodException ( ...
precess the request
49,630
protected function getRequest ( $ method , $ uri , $ params , $ body ) { return $ this -> execute ( $ method , $ uri , $ params , $ body ) ; }
get request implementation
49,631
protected function deleteRequest ( $ method , $ uri , $ params , $ body ) { return $ this -> execute ( $ method , $ uri , $ params , $ body ) ; }
delete request implementation
49,632
protected function headRequest ( $ method , $ uri , $ params , $ body ) { return $ this -> execute ( $ method , $ uri , $ params , $ body ) ; }
head request implementation
49,633
protected function postRequest ( $ method , $ uri , $ params , $ body ) { return $ this -> execute ( $ method , $ uri , $ params , $ body ) ; }
post request implementation
49,634
protected function putRequest ( $ method , $ uri , $ params , $ body ) { $ this -> checkBody ( $ body , $ method ) ; $ this -> setHttpHeader ( 'Content-Length: ' . strlen ( $ body ) ) ; return $ this -> execute ( $ method , $ uri , $ params , $ body ) ; }
put request implementation
49,635
protected function prepareResponse ( $ result ) { $ this -> checkForCurlErrors ( ) ; $ response = array ( ) ; $ response [ "data" ] = $ this -> getSerializer ( ) -> deserialize ( $ result ) ; $ response [ "status" ] = $ this -> getStatusCode ( ) ; if ( $ response [ 'status' ] >= 400 && $ response [ 'status' ] < 500 ) {...
prepares the response
49,636
protected function checkForCurlErrors ( ) { if ( curl_errno ( $ this -> getHandle ( ) ) ) { $ exceptionText = "Connection Error: " . curl_error ( $ this -> getHandle ( ) ) ; throw new ConnectionException ( $ exceptionText ) ; } }
checks if a curl error occurred
49,637
public function enableSSL ( $ strict = false ) { $ this -> setScheme ( self :: SCHEME_SSL ) ; if ( $ strict === false ) { $ this -> setOption ( CURLOPT_SSL_VERIFYPEER , 0 ) ; $ this -> setOption ( CURLOPT_SSL_VERIFYHOST , 0 ) ; } else { $ this -> setOption ( CURLOPT_SSL_VERIFYPEER , 0 ) ; $ this -> setOption ( CURLOPT_...
Enables ssl for the connection
49,638
protected function buildUrl ( $ uri , $ params ) { $ host = $ this -> buildHostString ( ) ; if ( strpos ( $ uri , "/" ) !== 0 ) { $ uri = "/" . $ uri ; } $ url = $ host . $ uri ; if ( $ params === null ) { $ params = array ( ) ; } $ url .= $ this -> buildQueryString ( $ params ) ; return $ url ; }
build complete url
49,639
protected function buildQueryString ( array $ params ) { $ qs = "" ; foreach ( $ params as $ key => $ value ) { if ( $ qs === "" ) { $ qs = "?" ; } else { $ qs .= "&&" ; } $ qs .= $ key . "=" . $ value ; } return $ qs ; }
build the query string
49,640
protected function prepareHost ( $ scheme , $ host ) { $ host = $ this -> stripScheme ( $ host ) ; if ( substr ( $ host , - 1 ) === "/" ) { $ host = substr ( $ host , 0 , - 1 ) ; } return $ scheme . $ host ; }
Adds given scheme to hostname
49,641
public function setHttpHeader ( $ header ) { $ headers = $ this -> getHttpHeaders ( ) ; $ headers [ ] = $ header ; $ this -> setHttpHeaders ( $ headers ) ; }
Adds a new http header to header list
49,642
function Html ( ) { $ text = $ this -> html ; $ pos = strpos ( $ text , self :: $ placeholder ) ; $ phLength = strlen ( self :: $ placeholder ) ; while ( $ pos !== false && $ this -> currentChild ) { $ replacement = $ this -> RenderCurrentChild ( ) ; $ text = substr ( $ text , 0 , $ pos ) . $ replacement . substr ( $ t...
Gathers the html
49,643
protected function buildRunnable ( StdClass $ runnable ) { $ template = __DIR__ . '/template' . '/RunnableTemplate.phx' ; if ( ! file_exists ( $ template ) ) { $ this -> cmd -> error ( sprinf ( 'Template file [%s] does not exist' , $ template ) , 'red' ) ; exit ; } $ content = file_get_contents ( $ template ) ; $ hasLa...
Creates a new runnable object .
49,644
protected function validateArgumentLengthType ( String $ argument ) { if ( ! is_numeric ( $ argument ) && ! in_array ( $ argument , [ 'none' , 'i' ] ) ) { $ this -> cmd -> error ( sprintf ( 'Failed to create runnable. [%s] is not a valid argument length type.' , $ argument ) ) ; } if ( in_array ( $ argument , [ 'none' ...
Checks and validates the argument type returned .
49,645
public function find ( Request $ request ) { $ route = $ this -> getRouteFinder ( ) -> find ( $ request , $ this -> getRoutes ( ) ) ; $ this -> setCurrentRoute ( $ route ) ; return $ route ; }
Finds a route from a uri .
49,646
public function getAllowedIdps ( $ spEntityId ) { if ( isset ( $ this -> allowedIdpsPerSp [ $ spEntityId ] ) ) { return $ this -> allowedIdpsPerSp [ $ spEntityId ] ; } $ this -> allowedIdpsPerSp [ $ spEntityId ] = $ this -> client -> getAllowedIdps ( $ spEntityId ) ; return $ this -> allowedIdpsPerSp [ $ spEntityId ] ;...
Retrieve the allowed IDPs for an SP . The SP is only allowed to make connections to the retrieved IDP s .
49,647
public function getEntity ( $ entityId ) { if ( isset ( $ this -> entities [ $ entityId ] ) ) { return $ this -> entities [ $ entityId ] ; } $ this -> entities [ $ entityId ] = $ this -> client -> getEntity ( $ entityId ) ; return $ this -> entities [ $ entityId ] ; }
Get full information for a given entity .
49,648
public function getIdpList ( $ keys = array ( ) , $ forSpEntityId = null ) { sort ( $ keys ) ; $ keysString = implode ( ',' , $ keys ) ; if ( isset ( $ this -> identityProvidersMetadata [ $ keysString ] [ $ forSpEntityId ] ) ) { return $ this -> identityProvidersMetadata [ $ keysString ] [ $ forSpEntityId ] ; } if ( ! ...
Retrieve a list of metadata values of all available IDP entities .
49,649
public function getSpList ( $ keys = array ( ) ) { sort ( $ keys ) ; $ keysString = implode ( ',' , $ keys ) ; if ( isset ( $ this -> serviceProvidersMetadata [ $ keysString ] ) ) { return $ this -> serviceProvidersMetadata [ $ keysString ] ; } $ this -> serviceProvidersMetadata [ $ keysString ] = $ this -> client -> g...
Retrieve a list of metadata values of all available SP entities .
49,650
static public function elapsed ( $ start , $ end ) { return [ 'time_elapsed' => self :: elapsedTime ( $ start , $ end ) , 'memory_usage_gap' => self :: elapsedMemory ( $ start , $ end ) , 'real_memory_usage' => self :: elapsedMemory ( $ start , $ end , true ) ] ; }
Get detailed benchmark
49,651
static public function elapsedMemory ( $ start , $ end , $ real_usage = false , $ inMB = true ) { $ start = isset ( self :: $ _marks [ $ start ] ) ? self :: $ _marks [ $ start ] [ 'memory_usage' ] : 0 ; $ end = isset ( self :: $ _marks [ $ end ] ) ? self :: $ _marks [ $ end ] [ 'memory_usage' ] : 0 ; $ elapsed = ! $ re...
Get elapsed memory between two marks
49,652
static public function elapsedTime ( $ start , $ end ) { $ start = isset ( self :: $ _marks [ $ start ] ) ? self :: $ _marks [ $ start ] [ 'time' ] : 0 ; $ end = isset ( self :: $ _marks [ $ end ] ) ? self :: $ _marks [ $ end ] [ 'time' ] : 0 ; return $ start ? round ( $ end - $ start , 10 ) : null ; }
Compute the elapsed time of two marks
49,653
public function field ( $ fieldnames ) { $ fieldnames = func_get_args ( ) ; foreach ( $ fieldnames as $ fieldname ) { if ( false === is_string ( $ fieldname ) ) { return trigger_error ( sprintf ( 'All fieldnames used in "%s"() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ fieldname ) ) , E_USER_ERR...
Add one or multiple validation rules to one or multiple fields
49,654
public function required ( $ required = null ) { if ( false === is_bool ( $ required ) && null !== $ required ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type boolean, "%s" given' , __METHOD__ , gettype ( $ required ) ) , E_USER_ERROR ) ; } if ( null === $ required ) { $ required = tr...
Set a rule that a field value can be empty or not
49,655
public function load ( $ classname , $ name = null ) { if ( false === is_string ( $ classname ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ classname ) ) , E_USER_ERROR ) ; } if ( null !== $ name && false === is_string ( $ name ) ) {...
Loads a custom validator rule with optional validator name
49,656
public function extend ( $ fields , $ closure , $ message ) { if ( false === is_array ( $ fields ) ) { $ fields = [ ( string ) $ fields ] ; } if ( false === ( gettype ( $ closure ) === 'object' ) ) { return trigger_error ( sprintf ( 'Argument 2 passed to %s() must be a valid callback function, "%s" given' , __METHOD__ ...
Add custom validation rule to one or multiple fields
49,657
public function getMessages ( $ fullnames = false ) { if ( false === is_bool ( $ fullnames ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type boolean, "%s" given' , __METHOD__ , gettype ( $ fullnames ) ) , E_USER_ERROR ) ; } $ instance = $ this -> getMessageInstance ( ) ; return $ ins...
Returns all the messages
49,658
public function getMessage ( $ fieldname ) { if ( false === is_string ( $ fieldname ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ fieldname ) ) , E_USER_ERROR ) ; } $ instance = $ this -> getMessageInstance ( ) ; $ short = $ instance...
Returns messages by fieldname
49,659
public function setPrefix ( $ prefix = null ) { if ( null !== $ prefix ) { if ( false === is_string ( $ prefix ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ prefix ) ) , E_USER_ERROR ) ; } $ this -> prefix = $ prefix ; } return $ thi...
Sets the prefix
49,660
private function addRule ( $ rule , $ field , $ parameters , $ closue = null , $ message = null ) { $ this -> rules [ ] = ( object ) [ 'rule' => $ rule , 'field' => $ field , 'parameters' => $ parameters , 'closure' => $ closue , 'prefix' => $ this -> getPrefix ( ) , 'message' => $ message , 'required' => true ] ; }
Add rule to validation
49,661
public function setAccessTokenType ( $ type , $ secret = null , $ algorithm = null ) { $ this -> access_token_type = $ type ; $ this -> access_token_secret = $ secret ; $ this -> access_token_algorithm = $ algorithm ; }
Set the access token type
49,662
private function generateMACSignature ( $ url , $ parameters , $ http_method ) { $ timestamp = time ( ) ; $ nonce = uniqid ( ) ; $ parsed_url = parse_url ( $ url ) ; if ( ! isset ( $ parsed_url [ 'port' ] ) ) { $ parsed_url [ 'port' ] = ( $ parsed_url [ 'scheme' ] == 'https' ) ? 443 : 80 ; } if ( $ http_method == self ...
Generate the MAC signature
49,663
private function convertToCamelCase ( $ grant_type ) { $ parts = explode ( '_' , $ grant_type ) ; array_walk ( $ parts , function ( & $ item ) { $ item = ucfirst ( $ item ) ; } ) ; return implode ( '' , $ parts ) ; }
Converts the class name to camel case
49,664
public function isLocked ( $ recover = true ) { $ myPid = getmypid ( ) ; if ( ! file_exists ( $ this -> pidFile ) ) { return false ; } $ lockPid = trim ( file_get_contents ( $ this -> pidFile ) ) ; if ( $ myPid == $ lockPid ) { return false ; } $ isRunning = $ this -> isProcessRunning ( $ lockPid ) ; if ( ! $ isRunning...
Check if this lockFile corresponds to a locked process
49,665
public function isProcessRunning ( $ pid ) { if ( ! $ pid ) { return false ; } $ running = posix_kill ( $ pid , 0 ) ; if ( ! $ running ) { return false ; } $ psExists = ! ( bool ) posix_get_last_error ( ) ; return $ psExists ; }
Check if a pid is running
49,666
public function getRunningPID ( ) { if ( ! file_exists ( $ this -> pidFile ) ) { return false ; } $ runPid = trim ( file_get_contents ( $ this -> pidFile ) ) ; if ( ! $ runPid ) { return false ; } return $ runPid ; }
Get agent pid
49,667
static public function guessByMimeType ( $ mimeType ) { switch ( substr ( $ mimeType , 0 , strpos ( $ mimeType , '/' ) ) ) { case 'audio' : return self :: AUDIO ; break ; case 'image' : return self :: IMAGE ; break ; case 'video' : return self :: VIDEO ; break ; } if ( preg_match ( '~zip|rar|compress~' , $ mimeType ) )...
Guess the type by mime type .
49,668
public function insertProtect ( array $ matches = [ ] ) { $ gen = md5 ( mt_rand ( ) ) ; $ s = ( new SessionInjector ) -> build ( ) ; $ s -> csrf = array_merge ( is_array ( $ s -> csrf ) ? $ s -> csrf : [ ] , [ md5 ( $ gen ) ] ) ; return $ matches [ 1 ] . '<input type="hidden" name="csrf" value="' . $ gen . '" />' . $ m...
Insert CSRF protect into forms
49,669
public static function pop ( string & $ str , string $ encoding = null ) { $ encoding = $ encoding ? : mb_internal_encoding ( ) ; $ last = mb_substr ( $ str , - 1 , null , $ encoding ) ; $ str = mb_substr ( $ str , 0 , - 1 , $ encoding ) ; return $ last ; }
Pop the character off the end of string
49,670
public static function shift ( string & $ str , string $ encoding = null ) { $ encoding = $ encoding ? : mb_internal_encoding ( ) ; $ first = mb_substr ( $ str , 0 , 1 , $ encoding ) ; $ str = mb_substr ( $ str , 1 , null , $ encoding ) ; return $ first ; }
Shift a character off the beginning of string
49,671
public static function cutStart ( string $ str , string $ subString = ' ' , bool $ repeat = false , bool $ caseSensitive = true ) : string { $ prepared = RegEx :: prepare ( $ subString , '/' ) ; $ regex = sprintf ( '/^%s/%s' , ( $ subString ? ( $ repeat ? RegexHelper :: quantifyGroup ( $ prepared , 0 ) : $ prepared ) :...
Cut substring from the beginning of string
49,672
public function getAllDownloads ( ) { try { $ directoryIterator = new \ DirectoryIterator ( $ this -> downloadDir ) ; $ downloads = [ ] ; foreach ( $ directoryIterator as $ file ) { if ( ! $ file -> isFile ( ) ) { continue ; } if ( "." === $ file -> getBasename ( ) [ 0 ] ) { continue ; } $ downloads [ $ file -> getFile...
Returns a list of all downloads
49,673
static function imageAdjustOrientation ( $ path ) { $ image = new \ imagick ( ) ; if ( ! $ image -> readImage ( $ path ) ) return FALSE ; $ orientation = $ image -> getImageOrientation ( ) ; $ rotated = false ; switch ( $ orientation ) { case \ imagick :: ORIENTATION_BOTTOMRIGHT : $ image -> rotateimage ( "#000" , 180 ...
If exif data indicates a rotated image we apply the transformation to the image and set back orientation to normal
49,674
public function indexAction ( Request $ request , PaginatorInterface $ paginator , TokenStorageInterface $ token_storage ) : Response { $ repo = $ this -> em -> getRepository ( Invitation :: class ) ; $ query = $ repo -> findPendingInvitationsQuery ( $ token_storage -> getToken ( ) -> getUser ( ) ) ; $ invitations = $ ...
Show a list of pending invitations for the current user .
49,675
public function respondAction ( int $ id , string $ response , AuthorizationCheckerInterface $ auth ) : Response { $ repo = $ this -> em -> getRepository ( Invitation :: class ) ; if ( null === $ invitation = $ repo -> findOneBy ( [ 'id' => $ id ] ) ) { throw new NotFoundHttpException ( ) ; } if ( ! $ auth -> isGranted...
Respond to an individual invitation .
49,676
public static function permission ( $ request = null , $ match = null ) { if ( ! $ request -> user || $ request -> user -> isAnonymous ( ) ) { return false ; } $ per = new User_Role ( ) ; $ sql = new Pluf_SQL ( 'code_name=%s' , array ( $ match [ 'metricName' ] ) ) ; $ items = $ per -> getList ( array ( 'filter' => $ sq...
Retruns permision status
49,677
private function fileLineGenerator ( string $ fileName , callable $ formatter = null ) { $ f = fopen ( $ fileName , 'r' ) ; try { while ( $ line = fgets ( $ f ) ) { if ( ! is_null ( $ formatter ) ) { yield call_user_func ( $ formatter , $ line ) ; } else { yield $ line ; } } } finally { fclose ( $ f ) ; } }
Read from a file one line at a time .
49,678
public function toWords ( $ todo = null ) { $ this -> toWords = true ; if ( $ todo !== null ) $ this -> todo = $ todo ; if ( $ this -> todo !== null ) return $ this -> doQuadrillion ( ) ; }
Converts the figure todo value to words
49,679
public function toFigure ( $ todo = null ) { $ this -> toWords = false ; if ( $ todo !== null ) $ this -> todo = $ todo ; if ( $ this -> todo !== null ) return $ this -> doQuadrillion ( ) ; }
Converts the word todo value to figure
49,680
protected function compileNestedJoinConstraint ( array $ clause ) { $ clauses = [ ] ; foreach ( $ clause [ 'join' ] -> clauses as $ nestedClause ) { $ clauses [ ] = $ this -> compileJoinConstraint ( $ nestedClause ) ; } $ clauses [ 0 ] = $ this -> removeLeadingBoolean ( $ clauses [ 0 ] ) ; $ clauses = implode ( ' ' , $...
Create a nested join clause constraint segment .
49,681
public function toArray ( ) { $ output = iterator_to_array ( $ this ) ; foreach ( $ output as $ index => $ value ) { if ( $ value instanceof self ) $ output [ $ index ] = $ value -> toArray ( ) ; } return $ output ; }
toArray will return turn itself into arrays
49,682
public function getLifetime ( ) { if ( ! self :: $ lifetime ) { $ sessionExpirationHours = engineGet ( 'Config' , 'sessionExpirationHours' , false ) ; if ( ! $ sessionExpirationHours ) $ sessionExpirationHours = 2 ; self :: $ lifetime = 60 * 60 * $ sessionExpirationHours ; } return self :: $ lifetime ; }
Fetch the life time for the session
49,683
public static function save ( $ key , $ value , $ duration = null ) { self :: setLifetime ( $ duration ) ; static :: init ( ) ; $ _SESSION [ self :: $ prepend . $ key ] = $ value ; }
Saves to session
49,684
public static function fetch ( $ key ) { static :: init ( ) ; if ( isset ( $ _SESSION [ self :: $ prepend . $ key ] ) ) return $ _SESSION [ self :: $ prepend . $ key ] ; }
Fetches from session
49,685
public static function remove ( $ key ) { static :: init ( ) ; if ( isset ( $ _SESSION [ self :: $ prepend . $ key ] ) ) unset ( $ _SESSION [ self :: $ prepend . $ key ] ) ; }
Removes from session
49,686
public function run ( $ data ) { $ this -> task -> addValues ( $ data ) ; if ( $ this -> task -> validate ( ) === true ) { return $ this -> task -> run ( ) ; } $ errors = $ this -> task -> getErrors ( ) ; Env :: error ( $ this -> formatErrors ( $ errors ) ) ; }
Run a task
49,687
public static function makeFromObject ( $ object ) { $ refl = new \ ReflectionClass ( __CLASS__ ) ; $ obj = $ refl -> newInstanceWithoutConstructor ( ) ; $ obj -> isValid = true ; $ obj -> decoded = $ object ; return $ obj ; }
Static entry point to generate a json_object from something that can be json_serialized We don t need to validate or calc the json representation as this can be calculated lazily
49,688
public function isValid ( & $ exception = null ) { $ exception = null ; if ( $ this -> isValid === null ) { $ this -> decoded = @ json_decode ( $ this -> json , true ) ; if ( null === $ this -> decoded and JSON_ERROR_NONE !== $ lastError = json_last_error ( ) ) { $ this -> isValid = new BadJsonException ( $ this -> jso...
Does or json object contain valid json
49,689
public static function create ( LoopInterface $ loop , callable $ check , $ value = null , $ iterations = 1 ) { return ( new self ( $ loop , $ check , $ value , $ iterations ) ) -> run ( ) ; }
Factory used by tickingFuturePromise see there for more details .
49,690
protected function run ( ) { futurePromise ( $ this -> loop ) -> then ( function ( ) : void { $ this -> check ( ) ; } ) ; return $ this -> deferred -> promise ( ) ; }
Run the ticking future promise .
49,691
public function validate ( $ value ) { return is_int ( $ value ) ? Ok :: unit ( ) : Error :: unit ( [ Error :: NON_INT ] ) ; }
Tells if a given value is a valid int .
49,692
public function format ( \ Throwable $ e , $ h1 ) { return $ this -> body ( $ e , $ h1 , $ this -> _stackTraceFormatter -> format ( new StackTrace ( $ e ) ) ) ; }
Format an exception as a string with suitable format
49,693
public function execute ( $ key = null , $ default = null , $ data = null ) { if ( is_array ( $ key ) ) { foreach ( $ key as $ index ) { if ( ! isset ( $ data [ $ index ] ) ) { return $ default ; } $ data = $ data [ $ index ] ; } return $ data ; } if ( $ key && isset ( $ data [ $ key ] ) ) { return $ data [ $ key ] ; }...
Get value from array string
49,694
public static function make ( array $ data , array $ rules , $ unknown = null , $ custom = [ ] ) { $ factory = new ValidatorFactory ( ) ; if ( is_array ( $ unknown ) && count ( $ unknown ) > 0 ) { $ custom = $ unknown ; } $ response = $ factory -> make ( $ data , $ rules , $ custom ) ; if ( isset ( $ _SERVER [ 'HTTP_X_...
Make a new validator
49,695
protected function NextItem ( ) { if ( $ this -> used ) $ this -> iterator -> next ( ) ; $ this -> used = true ; return $ this -> iterator -> current ( ) ; }
NextItem This function is used if the caller uses MoveNext on the iterator
49,696
public function fetchData ( ) { if ( isset ( $ _SERVER [ $ this -> options [ "environment" ] ] ) ) { $ message = "Using token from environent" ; $ header = $ _SERVER [ $ this -> options [ "environment" ] ] ; } else { $ message = "Using token from request header" ; $ header = $ this -> app -> request -> headers ( "Autho...
Fetch the access token
49,697
protected function setArrayToStringForUrl ( $ sSeparator , $ aElements , $ aExceptedElements = [ '' ] ) { $ outArray = $ this -> normalizeArrayForUrl ( $ aElements ) ; if ( count ( $ outArray ) < 1 ) { return '' ; } $ xptArray = $ this -> normalizeArrayForUrl ( $ aExceptedElements ) ; $ finalArray = array_diff_key ( $ ...
Converts an array to string
49,698
private function setStartingPageRecord ( $ sDefaultPageNo , $ iRecordsPerPage , $ iAllRecords , $ bKeepFullPage = true ) { if ( is_null ( $ this -> tCmnSuperGlobals -> get ( 'page' ) ) ) { switch ( $ sDefaultPageNo ) { case 'last' : $ iStartingPageRecord = $ iAllRecords - $ iRecordsPerPage ; break ; case 'first' : defa...
Returns starting records for LIMIT clause on SQL interrogation
49,699
public function validateUniqueLink ( $ attribute ) { $ params = Yii :: $ app -> request -> get ( ) ; $ query = PageLang :: find ( ) -> joinWith ( 'page' ) -> andWhere ( [ PageLang :: tableName ( ) . '.language' => Yii :: $ app -> wavecms -> editedLanguage , PageLang :: tableName ( ) . '.link' => $ this -> link ] ) ; if...
Validator for unique link per language