idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
14,400 | public function getCacheInfo ( ) { if ( ( $ cachePath = $ this -> folder -> getCachePath ( TRUE ) ) ) { $ size = 0 ; $ count = 0 ; $ di = new \ DirectoryIterator ( $ cachePath ) ; foreach ( $ di as $ fileinfo ) { if ( $ fileinfo -> isDot ( ) || ! $ fileinfo -> isFile ( ) || strpos ( $ fileinfo -> getFilename ( ) , $ th... | retrieve information about cached files |
14,401 | public static function getFilesystemFilesInFolder ( FilesystemFolder $ folder ) { $ files = [ ] ; $ glob = glob ( $ folder -> getPath ( ) . '*' , GLOB_NOSORT ) ; if ( $ glob !== FALSE ) { foreach ( $ glob as $ f ) { if ( ! is_dir ( $ f ) ) { if ( ! isset ( self :: $ instances [ $ f ] ) ) { self :: $ instances [ $ f ] =... | return all filesystem files instances within a certain folder |
14,402 | public function setFetchOptions ( $ fetchOptions ) { if ( $ fetchOptions === null ) { return $ this -> fetchOptions ; } if ( ! is_integer ( $ fetchOptions ) ) { throw new BadTypeException ( $ fetchOptions , 'int' ) ; } $ fetchOptions += $ fetchOptions & ( self :: TYPE_DETECT | self :: TYPE_AGNOSTIC ) ? 0 : self :: TYPE... | Set the result fetchOptions |
14,403 | private function buildFetchCallback ( $ fetchOptions , $ flatten ) { $ original = $ this -> fetchOptions & ( self :: TYPE_DETECT | self :: TYPE_AGNOSTIC | self :: FLATTEN_IF_POSSIBLE | self :: FLATTEN_PREVENT | self :: STYLE_ASSOC | self :: STYLE_NUM ) ; $ new = $ fetchOptions & ( self :: TYPE_DETECT | self :: TYPE_AGN... | Build a row processing callback based on the TYPE_DETECT and row flattening |
14,404 | public function getFetchOptions ( & $ humanReadable = null ) { if ( func_num_args ( ) ) { $ humanReadable = [ ] ; $ refl = new \ ReflectionClass ( __CLASS__ ) ; foreach ( $ refl -> getConstants ( ) as $ name => $ value ) { if ( $ value & $ this -> fetchOptions and strpos ( $ name , 'DEFAULT' ) === false ) { $ humanRead... | Return the bitmask |
14,405 | public function fetch ( $ options = null , $ keyResultsByColumn = null ) { $ this -> setFetchOptions ( $ options ) ; if ( $ this -> fetchOptions & self :: CACHE ) { $ cacheKey = $ this -> fetchOptions & ( self :: TYPE_DETECT | self :: TYPE_AGNOSTIC | self :: FLATTEN_IF_POSSIBLE | self :: FLATTEN_PREVENT | self :: STYLE... | Here be the magic! |
14,406 | public function getFieldTypeCallbacks ( ) { $ types = array ( ) ; $ numFields = $ this -> numFields ( ) ; for ( $ i = 0 ; $ i < $ numFields ; $ i ++ ) { $ types [ pg_field_name ( $ this -> resource , $ i ) ] = TypeConversionFactory :: get ( pg_field_type ( $ this -> resource , $ i ) , $ this ) ; } return $ types ; } | Return a array of php callbacks to be applied to a result set |
14,407 | public function getOption ( $ char = '' , $ name = '' , $ required = null ) { if ( ! $ char && ! $ name ) { return false ; } if ( $ char && ( 1 < strlen ( $ char ) || 1 !== preg_match ( '/^\w$/' , $ char ) ) ) { return false ; } if ( $ name && ( 1 !== preg_match ( '/^\w+$/' , $ name ) ) ) { return false ; } switch ( $ ... | Get arguments from command line |
14,408 | public function writeLines ( array $ bytes ) : int { $ bytesWritten = 0 ; foreach ( $ bytes as $ line ) { $ bytesWritten += $ this -> writeLine ( $ line ) ; } return $ bytesWritten ; } | writes given bytes and appends a line break after each one |
14,409 | protected function setDataEditSettings ( ) { $ header = $ this -> getData ( 'settings.header' ) ; if ( is_array ( $ header ) ) { $ string = '' ; foreach ( $ header as $ key => $ value ) { $ string .= "$key $value" . PHP_EOL ; } $ this -> setData ( 'settings.header' , trim ( $ string ) ) ; } } | Prepare data before rendering |
14,410 | protected function validateHeaderSettings ( ) { $ errors = $ header = array ( ) ; $ lines = gplcart_string_explode_multiline ( $ this -> getSubmitted ( 'header' , '' ) ) ; foreach ( $ lines as $ pos => $ line ) { $ pos ++ ; $ data = array_filter ( array_map ( 'trim' , explode ( ' ' , $ line , 2 ) ) ) ; if ( count ( $ d... | Validate header mapping |
14,411 | public static function addDecoder ( string $ class , string ... $ contentTypes ) { $ interface = decoder \ DecoderInterface :: class ; if ( ! is_subclass_of ( $ class , $ interface ) ) { throw new \ InvalidArgumentException ( "invalid value provided for 'class'; " . "expecting the name of a class that implements '$inte... | Replace existing decoders or add additional decoders |
14,412 | protected function getDecoder ( string $ stream , string $ contentType , int $ contentLength , decoder \ DecoderOptions $ options ) { $ type = \ sndsgd \ Str :: before ( $ contentType , ";" ) ; if ( ! isset ( static :: $ decoders [ $ type ] ) ) { throw new exception \ BadRequestException ( "failed to decode request bod... | Stubbable method for creating a decoder instance |
14,413 | private function checkMessage ( $ defMsg , array $ options ) { if ( is_array ( $ options ) && isset ( $ options [ 'message' ] ) ) return $ options [ 'message' ] ? $ options [ 'message' ] : null ; return $ defMsg ; } | Checks if a custom message exists or returns the default |
14,414 | public function required ( $ options ) { if ( ( is_array ( $ options ) || ( ! is_array ( $ options ) && $ options ) ) ) { if ( ( is_array ( $ this -> elementData ) && ( empty ( $ this -> elementData ) || ( empty ( $ this -> elementData [ 0 ] ) && count ( $ this -> elementData ) === 1 ) ) ) || ( ! is_array ( $ this -> e... | Makes an element required |
14,415 | public function match ( array $ options ) { if ( isset ( $ options [ 'element' ] ) ) { if ( isset ( $ this -> data [ $ options [ 'element' ] ] ) ) { if ( $ this -> elementData == $ this -> data [ $ options [ 'element' ] ] ) { return true ; } } else { return true ; } } else if ( isset ( $ options [ 'value' ] ) ) { if ( ... | Checks if the value of the element matches the given option |
14,416 | public function email ( array $ options ) { if ( empty ( $ this -> elementData ) || filter_var ( $ this -> elementData , FILTER_VALIDATE_EMAIL ) ) { $ this -> elementData = filter_var ( $ this -> elementData , FILTER_SANITIZE_EMAIL ) ; return true ; } $ this -> addError ( $ this -> checkMessage ( 'Invalid email adddres... | Checks if the value of the element is a valid email address |
14,417 | public function url ( array $ options ) { if ( empty ( $ this -> elementData ) || filter_var ( $ this -> elementData , FILTER_VALIDATE_URL ) ) { $ this -> elementData = filter_var ( $ this -> elementData , FILTER_SANITIZE_URL ) ; return true ; } $ this -> addError ( $ this -> checkMessage ( 'Value is not a valid url' ,... | Checks if the values of the element is a valid url |
14,418 | public function alpha ( array $ options ) { if ( ! $ options [ 'regex' ] ) $ options [ 'regex' ] = ( $ options [ 'acceptSpace' ] ) ? '/[^a-zA-Z\s]/' : '/[^a-zA-Z]/' ; if ( ! preg_match ( $ options [ 'regex' ] , $ this -> elementData ) ) return true ; $ this -> addError ( $ this -> checkMessage ( 'Value can only contain... | Checks if the contents of the element are all alphabets |
14,419 | public function decimal ( array $ options ) { if ( ctype_digit ( $ this -> elementData ) ) return true ; $ this -> addError ( $ this -> checkMessage ( 'Value can only contain numbers and a dot' , $ options ) ) ; return false ; } | Checks if the content of the element is decimal |
14,420 | public function greaterThan ( array $ options ) { if ( isset ( $ options [ 'element' ] ) ) { if ( isset ( $ this -> data [ $ options [ 'element' ] ] ) ) { $ than = ' "' . $ this -> cleanElement ( $ options [ 'element' ] ) . '"' ; if ( $ this -> elementData > $ this -> data [ $ options [ 'element' ] ] || ( empty ( $ thi... | Checks if the value of the element is greater than the given value |
14,421 | public function lessThan ( array $ options ) { if ( isset ( $ options [ 'element' ] ) ) { if ( isset ( $ this -> data [ $ options [ 'element' ] ] ) ) { $ than = ' "' . $ this -> cleanElement ( $ options [ 'element' ] ) . '"' ; if ( $ this -> elementData < $ this -> data [ $ options [ 'element' ] ] ) { return true ; } }... | Checks if the value of the element is less than the given value |
14,422 | public function minLength ( array $ options ) { if ( $ options [ 'value' ] && strlen ( $ this -> elementData ) >= $ options [ 'value' ] ) return true ; $ this -> addError ( $ this -> checkMessage ( 'Length must not be less than ' . $ options [ 'value' ] , $ options ) ) ; return false ; } | Checks if the length of the value of the element is not less than the required length |
14,423 | public function main ( ) { $ this -> out ( 'CodeBlastr Queue Plugin:' ) ; $ this -> hr ( ) ; $ this -> out ( 'Usage:' ) ; $ this -> out ( ' cake CodeBlastr.Queue help' ) ; $ this -> out ( ' -> Display this Help message' ) ; $ this -> out ( ' cake Queue.Queue runworker' ) ; $ this -> out ( ' -> run a queue worker, whi... | Output some basic usage Info . |
14,424 | public final function dispose ( ) { if ( $ this -> disposed ) { return ; } if ( \ is_resource ( $ this -> r ) ) { \ imagedestroy ( $ this -> r ) ; } $ this -> r = null ; $ this -> size = null ; $ this -> colors = [ ] ; $ this -> mimeType = null ; $ this -> _file = null ; $ this -> disposed = true ; } | Disposes the current image resource . |
14,425 | public final function output ( int $ quality = 60 , string $ filename = null ) { \ header ( 'Expires: 0' ) ; \ header ( 'Cache-Control: private' ) ; \ header ( 'Pragma: cache' ) ; if ( empty ( $ filename ) ) { $ filename = \ basename ( $ this -> _file ) ; } else { $ filename = \ basename ( $ filename ) ; } if ( ! empty... | Outputs the current image including all required HTTP headers and exit the script . |
14,426 | public final function negate ( bool $ internal = false ) : GdImage { if ( ! $ internal ) { $ clon = clone $ this ; return $ clon -> negate ( true ) ; } $ w = $ this -> getWidth ( ) ; $ h = $ this -> getHeight ( ) ; $ im = \ imagecreatetruecolor ( $ w , $ h ) ; for ( $ y = 0 ; $ y < $ h ; ++ $ y ) { for ( $ x = 0 ; $ x ... | Creates a negative of current image . |
14,427 | public final function cropRect ( Rectangle $ rect , bool $ internal = true ) : IImage { $ thumb = \ imagecreatetruecolor ( $ rect -> size -> getWidth ( ) , $ rect -> size -> getHeight ( ) ) ; if ( $ this -> mimeType == 'image/gif' || $ this -> mimeType == 'image/png' ) { \ imagealphablending ( $ thumb , false ) ; \ ima... | Crop the defined image part and returns the current or new image instance . |
14,428 | public final function contract ( int $ percent , bool $ internal = true ) : IImage { if ( $ percent < 1 || $ percent >= 100 ) { throw new ArgumentError ( 'percent' , $ percent , 'Drawing.Image' , 'Image dimension contraction must produce a smaller, non zero sized image!' ) ; } $ newWidth = \ intval ( \ floor ( $ this -... | Reduce the original image size by the specified percentage value . |
14,429 | public final function contractToMaxSize ( Size $ maxsize , bool $ internal = true ) : IImage { if ( $ maxsize -> getWidth ( ) >= $ this -> size -> getWidth ( ) && $ maxsize -> getHeight ( ) >= $ this -> size -> getHeight ( ) ) { return $ this -> returnSelf ( $ internal ) ; } $ newSize = new Size ( $ this -> size -> get... | Reduce the original image size by holding the image size proportion to fit best the declared maximum size . |
14,430 | public final function drawSingleBorder ( $ borderColor , bool $ internal = true ) : IImage { $ borderColor = $ this -> getGdColorObject ( $ borderColor , 'bordercolor' ) ; if ( $ internal ) { \ imagerectangle ( $ this -> r , 1 , 1 , $ this -> getWidth ( ) - 2 , $ this -> getHeight ( ) - 2 , $ borderColor -> getGdValue ... | Draws a single border with defined color around the image . |
14,431 | public final function drawDoubleBorder ( $ innerBorderColor , $ outerBorderColor , bool $ internal = true ) : IImage { $ innerBorderColor = $ this -> getGdColorObject ( $ innerBorderColor , 'bordercolor' ) ; $ outerBorderColor = $ this -> getGdColorObject ( $ outerBorderColor , 'outerbordercolor' ) ; if ( $ internal ) ... | Draws a double border with defined colors around the image . |
14,432 | public final function drawText ( string $ text , $ font , $ fontSize , $ color , Point $ point , bool $ internal = true ) : IImage { $ color = $ this -> getGdColorObject ( $ color , 'textcolor' ) ; if ( ! empty ( $ font ) && \ file_exists ( $ font ) ) { if ( $ internal ) { \ imagettftext ( $ this -> r , $ fontSize , 0 ... | Draws a text at declared position into current image . |
14,433 | public function commit ( ) { if ( $ this -> _initialized && $ this -> _dirty ) { $ this -> _saveCache ( ) ; $ this -> _dirty = false ; } } | Commit cache content updates to storage |
14,434 | protected function redirectToRoute ( string $ route , $ parameters = [ ] , int $ status = 302 ) : RedirectResponse { return $ this -> redirect ( $ this -> generateUrl ( $ route , $ parameters ) , $ status ) ; } | Returns a RedirectResponse to the given route with the given parameters . Overwrites Controller - trait to allow parameters as object as well . |
14,435 | protected function isDeletable ( $ object ) : bool { $ em = $ this -> getEntityManager ( ) ; $ em -> beginTransaction ( ) ; try { if ( $ object instanceof SoftDeleteableInterface ) { $ object -> setDeletedAt ( new \ DateTime ( ) ) ; } $ em -> remove ( $ object ) ; $ em -> flush ( ) ; $ em -> rollback ( ) ; return true ... | Tries to delete an object without actually deleting it . Returns false if ForeignKeyConstraintViolationException would be thrown ; true otherwise . |
14,436 | public function createFromFile ( $ file ) { if ( ! $ file || ! file_exists ( $ file ) ) { throw new \ Exception ( "Configuration file \"{$file}\" could not be found." ) ; } $ config = @ include ( $ file ) ; if ( ! $ config ) { throw new \ Exception ( "Configuration file \"{$file}\" could not be included." ) ; } $ this ... | Creates a configuration object by loading the parameters from a file . This file has to be a PHP file returning an array with the parameters . |
14,437 | public static function TryParseArray ( & $ refLocale , array $ requestData , array $ acceptedKeys = [ 'locale' , 'language' , 'lang' , 'loc' , 'lc' , 'lng' ] ) : bool { if ( \ count ( $ requestData ) < 1 ) { return false ; } $ requestData = \ array_change_key_case ( $ requestData , \ CASE_LOWER ) ; $ acceptedKeys = \ a... | Tries to create a new Locale instance from defined array . It accepts one of the following array keys to declare an |
14,438 | public function get ( array $ adapters , CacheableInterface $ item ) { foreach ( $ adapters as $ adapter ) { try { return $ adapter -> get ( $ item ) ; } catch ( \ Exception $ e ) { continue ; } } throw new UnhandledCacheException ( 'No cache system is available' ) ; } | Get cache from first up adapter |
14,439 | public function remove ( array $ adapters , CacheableInterface $ item ) { foreach ( $ adapters as $ adapter ) { $ adapter -> remove ( $ item ) ; } } | Remove cache from all adapters |
14,440 | public function queueUnresolvedObjects ( $ data , $ relations ) { if ( is_object ( $ data ) ) { if ( $ data instanceof Model ) { $ data = $ data -> getData ( ) ; } if ( ! $ this -> resolved ( $ data ) ) { $ this -> addToQueue ( $ data , $ relations ) ; return ; } $ data = get_object_vars ( $ data ) ; } if ( is_array ( ... | Add unresovled objects to load queue |
14,441 | protected function resolved ( $ obj ) { if ( ! is_object ( $ obj ) ) { return true ; } $ data = get_object_vars ( $ obj ) ; if ( count ( $ data ) == 2 && array_key_exists ( 'id' , $ data ) && array_key_exists ( 'type' , $ data ) ) { return false ; } return true ; } | Check if object is resolved |
14,442 | protected function addToQueue ( $ object , $ relations ) { if ( ! array_key_exists ( $ object -> type , self :: $ loadQueue ) ) { self :: $ loadQueue [ $ object -> type ] = [ ] ; } $ relationsKey = base64_encode ( json_encode ( $ relations ) ) ; if ( ! array_key_exists ( $ relationsKey , self :: $ loadQueue [ $ object ... | Add object to loadQueue if it s specified in relations |
14,443 | protected function _scheduleVars ( ) { global $ argv ; $ path = $ argv [ 2 ] . DS ; $ shellName = $ argv [ 3 ] ; $ taskName = $ argv [ 4 ] ; if ( isset ( $ this -> args [ 0 ] ) && $ this -> hasMethod ( $ this -> args [ 0 ] ) ) { $ methodName = $ this -> args [ 0 ] ; array_shift ( $ this -> args ) ; } else { $ methodNam... | Returns variables for schedule |
14,444 | protected function _schedule ( $ command , $ path , array $ arguments , array $ options ) { $ TaskClient = ClassRegistry :: init ( 'Task.TaskClient' ) ; $ task = $ TaskClient -> add ( $ command , $ path , $ arguments , $ options ) ; if ( $ task ) { $ waitFor = empty ( $ options [ 'dependsOn' ] ) ? 'none' : implode ( ',... | Adds script to sceduler |
14,445 | protected function _getInterval ( $ interval ) { if ( $ interval !== null ) { return $ interval ; } elseif ( ! empty ( $ this -> params [ 'interval' ] ) ) { return $ this -> params [ 'interval' ] ; } else { return '1 day' ; } } | Returns interval value specified by parameter or default value |
14,446 | public function getTaxesAmounts ( ) { $ amounts = new TaxesAmounts ( ) ; $ amounts -> addTaxAmount ( new TaxAmount ( $ this -> tax , $ this -> getTaxAmount ( ) ) ) ; return $ amounts ; } | Returns the taxes amounts . |
14,447 | public function config ( $ parameter ) { $ value = $ this -> configService -> getParameter ( $ parameter ) ; return is_array ( $ value ) ? json_encode ( $ value ) : $ value ; } | Returns the specified parameter |
14,448 | public function actionGetPaymentMethodInfo ( $ id ) { if ( \ Yii :: $ app -> request -> isAjax ) { if ( ! empty ( $ id ) ) { $ method = PaymentMethod :: findOne ( $ id ) ; $ methodTranslation = $ method -> translation ; $ method = ArrayHelper :: toArray ( $ method ) ; $ method [ 'translation' ] = ArrayHelper :: toArray... | Returns payment method model if request is Ajax . |
14,449 | public static function getItem ( $ namespace , $ key ) { if ( isset ( static :: $ _STORAGE [ $ namespace ] ) ) { if ( isset ( static :: $ _STORAGE [ $ namespace ] [ $ key ] ) ) { return static :: $ _STORAGE [ $ namespace ] [ $ key ] ; } } return NULL ; } | Get an Item from the Static Storage array |
14,450 | public static function setItem ( $ namespace , $ key , $ value ) { if ( ! isset ( static :: $ _STORAGE [ $ namespace ] ) ) { static :: $ _STORAGE [ $ namespace ] = array ( ) ; } static :: $ _STORAGE [ $ namespace ] [ $ key ] = $ value ; return TRUE ; } | Set an Item in the Static Storage array for a particular Namespace |
14,451 | public function addErrors ( Collection $ errors ) { $ this -> errors = $ this -> getErrors ( ) -> merge ( $ errors ) ; return $ this ; } | Add errors . |
14,452 | protected function createItem ( $ key ) { $ this -> validateKey ( $ key ) ; if ( is_callable ( $ this -> item_factory ) ) { $ func = $ this -> item_factory ; $ item = $ func ( $ key , $ this , $ this -> item_config ) ; } else { $ item = new CacheItem ( $ key , $ this , $ this -> item_config ) ; } return $ item ; } | Create item object |
14,453 | public function toArray ( ) { $ classData = [ ] ; foreach ( $ this -> getReflector ( ) -> getProperties ( \ ReflectionProperty :: IS_PROTECTED ) as $ reflectionProperty ) { if ( ! $ reflectionProperty -> isStatic ( ) ) { $ reflectionProperty -> setAccessible ( true ) ; $ classData [ $ reflectionProperty -> getName ( ) ... | Fetch the array representation of the protected properties of an object . |
14,454 | public function fromArray ( array $ source ) { foreach ( $ this -> getReflector ( ) -> getProperties ( \ ReflectionProperty :: IS_PROTECTED ) as $ reflectionProperty ) { if ( ! $ reflectionProperty -> isStatic ( ) && isset ( $ source [ $ reflectionProperty -> getName ( ) ] ) ) { $ reflectionProperty -> setAccessible ( ... | Set protected propertie according to provided source . |
14,455 | public function getFieldsConfig ( ) { if ( null === $ this -> fieldsConfigList ) { $ this -> fieldsConfigList = [ ] ; foreach ( $ this -> getFields ( ) as $ field ) { $ reflectionProperty = $ this -> getReflector ( ) -> getProperty ( $ field ) ; $ docBlock = $ reflectionProperty -> getDocComment ( ) ; preg_match ( '/@v... | Fetch the var metadata for a field and store it in the config . |
14,456 | public function getFieldType ( $ field ) { return isset ( $ this -> getFieldsConfig ( ) [ $ field ] ) ? $ this -> getFieldsConfig ( ) [ $ field ] [ 'type' ] : null ; } | Fetch a field type according to var metadata . |
14,457 | public function getUrlAttribute ( $ suffix = '' ) { if ( ! $ this -> exists ) { return Cache :: rememberForever ( 'missing_photo' , function ( ) { return static :: placeholder ( 'No photo provided' ) ; } ) ; } if ( ! $ this -> processed ) { return Cache :: rememberForever ( 'processing_photo' , function ( ) { return st... | Return the public URL for the photo . |
14,458 | public function delete ( ) { $ disk = Storage :: disk ( config ( 'mustard.storage.disk' , 'local' ) ) ; $ disk -> delete ( $ this -> getPath ( ) ) ; $ disk -> delete ( $ this -> getSmallPath ( ) ) ; $ disk -> delete ( $ this -> getLargePath ( ) ) ; parent :: delete ( ) ; } | Delete the record and data from the filesystem . |
14,459 | private static function placeholder ( $ text ) { $ image_manager = new ImageManager ( [ 'driver' => 'imagick' ] ) ; $ image = $ image_manager -> canvas ( 640 , 480 , '#efefef' ) ; $ image -> text ( $ text , 320 , 240 - ( 70 * substr_count ( $ text , "\n" ) ) , function ( $ font ) { $ font -> file ( base_path ( 'vendor/... | Return a placeholder image containing the provided text . |
14,460 | public static function upload ( $ file ) { $ photo = self :: create ( ) ; $ image_manager = new ImageManager ( [ 'driver' => 'imagick' ] ) ; $ disk = Storage :: disk ( config ( 'mustard.storage.disk' , 'local' ) ) ; if ( ! file_exists ( $ file ) ) { RuntimeException ( "File $file does not exist" ) ; } $ dest_dir = conf... | Process a photo and create a record . |
14,461 | public function boot ( ) { $ source = realpath ( $ raw = __DIR__ . '/Config.php' ) ? : $ raw ; if ( $ this -> app instanceof LaravelApplication && $ this -> app -> runningInConsole ( ) ) { $ this -> publishes ( [ $ source => config_path ( 'mutex.php' ) ] ) ; } elseif ( $ this -> app instanceof LumenApplication ) { $ th... | Bootstrap the configuration |
14,462 | public static function find ( array $ query ) { $ employees = Client :: get ( "employee" , $ query ) ; return array_map ( function ( $ data ) { return new self ( $ data ) ; } , $ employees ) ; } | Retrieve an array of Employee objects according to a search query . |
14,463 | public function getWorkPhone ( ) { if ( ! isset ( $ this -> workPhone ) ) { $ wp = trim ( $ this -> getRawWorkPhone ( ) ) ; if ( empty ( $ wp ) ) { $ this -> workPhone = null ; } else { if ( preg_match ( '/^\+?[-\d\s()]+/' , $ wp , $ matches ) ) { $ wp = $ matches [ 0 ] ; $ wp = trim ( str_replace ( [ '(' , ')' ] , '' ... | Get work phone number of this employee . Try to parse it to a PhoneNumber otherwise return the raw string . |
14,464 | public function find ( $ id , $ scopes = [ ] ) { return $ this -> _get ( 'servers/' . $ this -> server_id . '/software/' . $ id , null , $ scopes ) ; } | Gets a single software object on the server |
14,465 | public function exploits ( $ scopes = [ ] ) { if ( ! $ this -> id ) { throw new Exception ( "The software has no ID, can\'t get exploits" ) ; } if ( ! $ this -> server_id ) { throw new Exception ( "The software has no server ID, can\'t get exploits" ) ; } $ exploit = new Exploit ( $ this -> patrol ) ; $ exploit -> defa... | Gets a list of exploits from this software |
14,466 | protected function __valueSet ( $ key , $ value ) { if ( $ key === "exploits" ) { $ casted = [ ] ; foreach ( $ value as $ exploit ) { $ casted [ ] = new Exploit ( $ this -> patrol , $ exploit ) ; } return $ casted ; } return $ value ; } | This is a casting hook when a new value is set in PatrolModel this hook will be called in this case when exploits are set in the model cast them to a PatrolSdk \ Exploit object |
14,467 | protected function deduplicate ( $ lines ) { $ unique = array ( ) ; $ comments = array ( ) ; foreach ( $ lines as $ line ) { if ( strpos ( $ line , '/*' ) === 0 ) { $ comments [ ] = $ line ; continue ; } if ( ! in_array ( $ line , $ unique ) ) { $ unique [ ] = $ line ; } array_splice ( $ unique , array_search ( $ line ... | Deduplicate lines in a block . Comments are not deduplicated . If a duplicate rule is detected the comments immediately preceding each occurence are consolidated . |
14,468 | protected function findBlocks ( $ searchIn , $ path , $ orderedArgs , $ keywordArgs , $ seen = array ( ) ) { if ( $ searchIn == null ) return null ; if ( isset ( $ seen [ $ searchIn -> id ] ) ) return null ; $ seen [ $ searchIn -> id ] = true ; $ name = $ path [ 0 ] ; if ( isset ( $ searchIn -> children [ $ name ] ) ) ... | attempt to find blocks matched by path and args |
14,469 | protected function lib_data_uri ( $ value ) { $ mime = ( $ value [ 0 ] === 'list' ) ? $ value [ 2 ] [ 0 ] [ 2 ] : null ; $ url = ( $ value [ 0 ] === 'list' ) ? $ value [ 2 ] [ 1 ] [ 2 ] [ 0 ] : $ value [ 2 ] [ 0 ] ; $ fullpath = $ this -> findImport ( $ url ) ; if ( $ fullpath && ( $ fsize = filesize ( $ fullpath ) ) !... | Given an url decide whether to output a regular link or the base64 - encoded contents of the file |
14,470 | protected function toRGB ( $ color ) { if ( $ color [ 0 ] == 'color' ) return $ color ; $ H = $ color [ 1 ] / 360 ; $ S = $ color [ 2 ] / 100 ; $ L = $ color [ 3 ] / 100 ; if ( $ S == 0 ) { $ r = $ g = $ b = $ L ; } else { $ temp2 = $ L < 0.5 ? $ L * ( 1.0 + $ S ) : $ L + $ S - $ L * $ S ; $ temp1 = 2.0 * $ L - $ temp2... | Converts a hsl array into a color value in rgb . Expects H to be in range of 0 to 360 S and L in 0 to 100 |
14,471 | protected function funcToColor ( $ func ) { $ fname = $ func [ 1 ] ; if ( $ func [ 2 ] [ 0 ] != 'list' ) return false ; $ rawComponents = $ func [ 2 ] [ 2 ] ; if ( $ fname == 'hsl' || $ fname == 'hsla' ) { $ hsl = array ( 'hsl' ) ; $ i = 0 ; foreach ( $ rawComponents as $ c ) { $ val = $ this -> reduce ( $ c ) ; $ val ... | Convert the rgb rgba hsl color literals of function type as returned by the parser into values of color type . |
14,472 | protected function get ( $ name ) { $ current = $ this -> env ; $ isArguments = $ name == $ this -> vPrefix . 'arguments' ; while ( $ current ) { if ( $ isArguments && isset ( $ current -> arguments ) ) { return array ( 'list' , ' ' , $ current -> arguments ) ; } if ( isset ( $ current -> store [ $ name ] ) ) return $ ... | get the highest occurrence entry for a name |
14,473 | public function propertyValue ( & $ value , $ keyName = null ) { $ values = array ( ) ; if ( $ keyName !== null ) $ this -> env -> currentProperty = $ keyName ; $ s = null ; while ( $ this -> expressionList ( $ v ) ) { $ values [ ] = $ v ; $ s = $ this -> seek ( ) ; if ( ! $ this -> literal ( ',' ) ) break ; } if ( $ s... | consume a list of values for a property |
14,474 | protected function tag ( & $ tag , $ simple = false ) { if ( $ simple ) $ chars = '^@,:;{}\][>\(\) "\'' ; else $ chars = '^@,;{}["\'' ; $ s = $ this -> seek ( ) ; $ hasExpression = false ; $ parts = array ( ) ; while ( $ this -> tagBracket ( $ parts , $ hasExpression ) ) ; $ oldWhite = $ this -> eatWhiteDefault ; $ thi... | a space separated list of selectors |
14,475 | protected function func ( & $ func ) { $ s = $ this -> seek ( ) ; if ( $ this -> match ( '(%|[\w\-_][\w\-_:\.]+|[\w_])' , $ m ) && $ this -> literal ( '(' ) ) { $ fname = $ m [ 1 ] ; $ sPreArgs = $ this -> seek ( ) ; $ args = array ( ) ; while ( true ) { $ ss = $ this -> seek ( ) ; if ( $ this -> keyword ( $ name ) && ... | a css function |
14,476 | protected function assign ( $ name = null ) { if ( $ name ) $ this -> currentProperty = $ name ; return $ this -> literal ( ':' ) || $ this -> literal ( '=' ) ; } | Consume an assignment operator Can optionally take a name that will be set to the current property name |
14,477 | protected function append ( $ prop , $ pos = null ) { if ( $ pos !== null ) $ prop [ - 1 ] = $ pos ; $ this -> env -> props [ ] = $ prop ; } | append a property to the current block |
14,478 | public static function instance_from_curl ( $ ch , $ body ) { $ transfer_info = curl_getinfo ( $ ch ) ; $ statuscode = ( ! empty ( $ transfer_info [ 'http_code' ] ) ) ? ( int ) $ transfer_info [ 'http_code' ] : 404 ; $ errors = [ ] ; $ err = static :: decode_error_code ( curl_errno ( $ ch ) ) ; if ( $ err !== 'SUCCESS'... | Create an instance from a curl handle and body . |
14,479 | public function get_debug_string ( ) { return 'status: ' . $ this -> statuscode . ' body:' . htmlentities ( $ this -> body ) . ' errors: ' . print_r ( $ this -> errors , true ) ; } | Get a string with some basic information about the request . Usually put into the logs . |
14,480 | public function status_type ( ) { $ status_code_type = ( ! empty ( $ this -> statuscode ) ) ? ( int ) mb_substr ( $ this -> statuscode , 0 , 1 ) : 0 ; if ( $ status_code_type === 1 ) { $ status_type = 'informational' ; } elseif ( $ status_code_type === 2 ) { $ status_type = 'success' ; } elseif ( $ status_code_type ===... | Get the status type . |
14,481 | private function generateCode ( $ className , $ primaryKey ) { $ tags = $ this -> config -> getTags ( ) ; $ class = new ClassGenerator ( ) ; $ docblock = DocBlockGenerator :: fromArray ( array ( 'shortDescription' => ucfirst ( $ className ) . ' model class' , 'longDescription' => 'This is a model class generated with D... | Generate the code for the given className and primaryKey and write it in a file . |
14,482 | public function set ( $ key , $ value , $ expire = 3600 , $ path = '/' ) { if ( $ expire == false ) { setcookie ( $ key , serialize ( $ value ) , false , $ path ) ; } else { setcookie ( $ key , serialize ( $ value ) , time ( ) + $ expire , $ path ) ; } } | Adds to the session . |
14,483 | public function first ( callable $ fn = null , $ default = null ) { if ( is_null ( $ fn ) ) { return count ( $ this -> items ) > 0 ? reset ( $ this -> items ) : $ default ; } foreach ( $ this -> getIterator ( ) as $ value ) { if ( call_user_func ( $ fn , $ value ) ) { return $ value ; } } return $ default ; } | Retrieve the first element that matches the optional callback |
14,484 | public function last ( callable $ fn = null , $ default = null ) { if ( is_null ( $ fn ) ) { return count ( $ this -> items ) > 0 ? end ( $ this -> items ) : $ default ; } foreach ( array_reverse ( $ this -> items ) as $ value ) { if ( call_user_func ( $ fn , $ value ) ) { return $ value ; } } return $ default ; } | Receive the last element that matches the optional callback |
14,485 | public static function One ( $ id ) { $ class = get_called_class ( ) ; if ( ! isset ( self :: $ refs [ $ class ] [ $ id ] ) ) { $ file = self :: File ( $ id ) ; $ obj = unserialize ( file_get_contents ( $ file ) ) ; self :: $ refs [ $ class ] [ $ id ] = $ obj ; } return self :: $ refs [ $ class ] [ $ id ] ; } | Fetch one saved object by id |
14,486 | public static function SetDirectory ( $ dir ) { if ( ! is_dir ( $ dir ) ) { if ( ! @ \ mkdir ( $ dir , 0700 , TRUE ) ) { throw new \ InvalidArgumentException ( "dir $dir does not exist and could not be created" ) ; } } self :: $ DIR = realpath ( $ dir ) ; } | Set directory where all persistent objects and relations will be saved . |
14,487 | public function Save ( ) { if ( ! $ this -> Validate ( ) ) { throw new \ Exception ( "Validation failed" ) ; } $ file = self :: File ( $ this -> id ) ; if ( ! is_dir ( dirname ( $ file ) ) ) { mkdir ( dirname ( $ file ) , 0755 , true ) ; } file_put_contents ( $ file , serialize ( $ this ) , LOCK_EX ) ; return $ this ; ... | Save this object . |
14,488 | public static function extensionIdentifier ( string $ extensionKey ) : string { $ extensionIdentifier = GeneralUtility :: underscoredToUpperCamelCase ( $ extensionKey ) ; $ extensionIdentifier = mb_strtolower ( $ extensionIdentifier ) ; return $ extensionIdentifier ; } | Gets an extension identifier from an extension key . |
14,489 | public static function extensionSignature ( string $ namespace , string $ extensionKey , string $ separator = '.' ) : string { $ namespace = GeneralUtility :: underscoredToUpperCamelCase ( $ namespace ) ; $ extensionKey = GeneralUtility :: underscoredToUpperCamelCase ( $ extensionKey ) ; return "${namespace}${separator... | Gets an extension signature from a namespace and extension key . |
14,490 | public static function getExtensionSignature ( string $ namespace , string $ extensionKey , string $ separator = '.' ) : string { return self :: extensionSignature ( $ namespace , $ extensionKey , $ separator ) ; } | Alias for the extensionSignature function . |
14,491 | public static function locallang ( string $ extensionKey , string $ fileName = 'locallang.xlf' , string $ prefix = 'LLL:EXT:' , string $ separator = ':' ) : string { $ languageFolder = self :: languageFolder ( $ extensionKey , $ prefix ) ; return "${languageFolder}/${fileName}${separator}" ; } | Gets the locallang file from an extension key . |
14,492 | public static function getConfigurationFolder ( string $ extensionKey , string $ prefix = 'FILE:EXT:' ) : string { return self :: configurationFolder ( $ extensionKey , $ prefix ) ; } | Alias for the configurationFolder function . |
14,493 | public static function flexFormsFolder ( string $ extensionKey , string $ prefix = 'FILE:EXT:' ) : string { $ configurationFolder = self :: configurationFolder ( $ extensionKey , $ prefix ) ; return "${configurationFolder}/FlexForms" ; } | Gets the FlexForms folder from an extension key . |
14,494 | public static function getFlexFormsFolder ( string $ extensionKey , string $ prefix = 'FILE:EXT:' ) : string { return self :: flexFormsFolder ( $ extensionKey , $ prefix ) ; } | Alias for the flexFormsFolder function . |
14,495 | public static function getResourcesFolder ( string $ extensionKey , string $ prefix = 'EXT:' ) : string { return self :: resourcesFolder ( $ extensionKey , $ prefix ) ; } | Alias for the resourcesFolder function . |
14,496 | public static function privateFolder ( string $ extensionKey , string $ prefix = 'EXT:' ) : string { $ resourcesFolder = self :: resourcesFolder ( $ extensionKey , $ prefix ) ; return "${resourcesFolder}/Private" ; } | Gets the private folder from an extension key . |
14,497 | public static function getPrivateFolder ( string $ extensionKey , string $ prefix = 'EXT:' ) : string { return self :: privateFolder ( $ extensionKey , $ prefix ) ; } | Alias for the privateFolder function . |
14,498 | public static function languageFolder ( string $ extensionKey , string $ prefix = 'EXT:' ) : string { $ privateFolder = self :: privateFolder ( $ extensionKey , $ prefix ) ; return "${privateFolder}/Language" ; } | Gets the language folder from an extension key . |
14,499 | public static function getLanguageFolder ( string $ extensionKey , string $ prefix = 'EXT:' ) : string { return self :: languageFolder ( $ extensionKey , $ prefix ) ; } | Alias for the languageFolder function . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.