idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
13,500 | public static function lastIndexOf ( $ string , $ needle , $ strict = true , $ offset = 0 ) { if ( $ strict ) { return mb_strrpos ( $ string , $ needle , $ offset ) ; } return mb_strripos ( $ string , $ needle , $ offset ) ; } | Grab the index of the last matched character . |
13,501 | public static function listing ( $ items , $ glue = ' & ' , $ sep = ', ' ) { if ( is_array ( $ items ) ) { $ lastItem = array_pop ( $ items ) ; if ( count ( $ items ) === 0 ) { return $ lastItem ; } $ items = implode ( $ sep , $ items ) ; $ items = $ items . $ glue . $ lastItem ; } return $ items ; } | Creates a comma separated list with the last item having an ampersand prefixing it . |
13,502 | public static function shorten ( $ string , $ limit = 25 , $ glue = ' … ' ) { if ( mb_strlen ( $ string ) > $ limit ) { $ width = round ( $ limit / 2 ) ; $ pre = mb_substr ( $ string , 0 , $ width ) ; if ( mb_substr ( $ pre , - 1 ) !== ' ' && ( $ i = static :: lastIndexOf ( $ pre , ' ' ) ) ) { $ pre = mb_substr ... | If a string is too long shorten it in the middle while also respecting whitespace and preserving words . |
13,503 | public static function startsWith ( $ string , $ needle , $ strict = true ) { $ start = static :: extract ( $ string , 0 , mb_strlen ( $ needle ) ) ; if ( $ strict ) { return ( $ start === $ needle ) ; } return ( mb_strtolower ( $ start ) === mb_strtolower ( $ needle ) ) ; } | Checks to see if the string starts with a specific value . |
13,504 | protected function AddRichTextField ( $ name , $ value = '' ) { $ renderer = new CKEditorRenderer ( PathUtil :: BackendRTEPath ( ) , PathUtil :: BackendRTEUrl ( ) , PathUtil :: UploadPath ( ) , PathUtil :: UploadUrl ( ) , self :: Guard ( ) ) ; $ field = new Custom ( $ renderer ) ; $ field -> SetName ( $ name ) ; $ fiel... | Adds a field with the default rich text editor |
13,505 | function addpath ( $ name , $ fspath , $ overwrite = false ) { if ( ! $ overwrite && isset ( $ this -> registeredpaths [ $ name ] ) ) { throw new Panic ( "A path is already registered for $name." ) ; } else { $ this -> registeredpaths [ $ name ] = $ fspath ; } } | Registers a path under a specified name . |
13,506 | function path ( $ name , $ null_on_failure = false ) { if ( ! isset ( $ this -> registeredpaths [ $ name ] ) ) { if ( $ null_on_failure ) { return null ; } else { throw new Panic ( "There is no path registered for $name." ) ; } } else { return $ this -> registeredpaths [ $ name ] ; } } | Retrieves the specified path . If the path is not registered the method will Panic unless the second parameter is set in which case it will just return null . |
13,507 | public function addListener ( DBListener $ listener , $ name = null ) { if ( $ name !== null ) $ this -> listeners -> offsetSet ( $ name , $ listener ) ; else $ this -> listeners -> append ( $ listener ) ; } | Adds a DBListener to listen on some events of the DB class |
13,508 | protected function triggerListeners ( $ method , array $ params = array ( ) ) { if ( $ this -> muteListeners === true ) return ; $ this -> muteListeners = true ; foreach ( $ this -> listeners as $ l ) { call_user_func_array ( array ( $ l , $ method ) , $ params ) ; } $ this -> muteListeners = false ; } | Triggers a call of a specific method from all registered listener classes if the listeners are not set to mute |
13,509 | public function read ( $ chat , $ route , $ nameReader = 'random' ) { $ queue = new \ AMQPQueue ( $ this -> channel ) ; $ queue -> setName ( $ nameReader ) ; $ queue -> declare ( ) ; $ queue -> bind ( $ chat , $ route ) ; $ envelop = $ queue -> get ( ) ; if ( $ envelop ) { $ queue -> ack ( $ envelop -> getDeliveryTag (... | Read current message |
13,510 | public function readAll ( $ chat , $ route , $ nameReader ) { $ queue = new \ AMQPQueue ( $ this -> channel ) ; $ queue -> setName ( $ nameReader ) ; $ queue -> declare ( ) ; $ queue -> bind ( $ chat , $ route ) ; $ result = [ ] ; while ( $ envelop = $ queue -> get ( ) ) { $ queue -> ack ( $ envelop -> getDeliveryTag (... | Read all messages |
13,511 | final public function resizeImage ( $ width = null , $ height = null ) { if ( is_int ( $ width ) and is_int ( $ height ) ) { $ new_image = imagecreatetruecolor ( $ width , $ height ) ; imagecopyresampled ( $ new_image , $ this -> _image_handle , 0 , 0 , 0 , 0 , $ width , $ height , $ this -> imageWidth ( ) , $ this -> ... | Resize an image to an exact width and height |
13,512 | final public function rotateImage ( $ angle = 0 , array $ bgd_color = array ( 0 , 0 , 0 , 127 ) , $ ignore_transparent = false ) { $ this -> _image_handle = imagerotate ( $ this -> _image_handle , $ angle , $ this -> _createImageColorAlpha ( $ bgd_color ) , $ ignore_transparent ? 1 : 0 ) ; } | Rotate an image with a given angle |
13,513 | final protected function _createImageColorAlpha ( array $ rgba = array ( ) ) { $ keys = array ( 'r' , 'g' , 'b' , 'a' ) ; $ rgba = array_filter ( $ rgba , 'is_int' ) ; $ rgba = array_map ( 'abs' , $ rgba ) ; $ rgba = array_pad ( $ rgba , count ( $ keys ) , 0 ) ; $ rgba = array_slice ( $ rgba , 0 , count ( $ keys ) ) ; ... | Allocate a color for an image |
13,514 | final public function imagePNG ( $ filename = null , $ quality = - 1 , $ filters = PNG_NO_FILTER ) { return imagepng ( $ this -> _image_handle , $ filename , $ quality , $ filters ) ; } | Output a PNG image to either the browser or a file |
13,515 | final public function saveImage ( $ filename ) { $ extension = pathinfo ( $ filename , PATHINFO_EXTENSION ) ; if ( ! is_string ( $ extension ) ) { $ extension = image_type_to_extension ( $ this -> _image_type ) ; $ filename .= ".{$extension}" ; } switch ( strtolower ( $ extension ) ) { case 'jpeg' : case 'jpg' : return... | Generic save funciton which converts image according to extension |
13,516 | final public function imageAsDOMElement ( $ as = null ) { $ dom = new \ DOMDocument ( '1.0' , 'UTF-8' ) ; $ image = $ dom -> appendChild ( $ dom -> createElement ( 'img' ) ) ; $ image -> setAttribute ( 'height' , $ this -> imageHeight ( ) ) ; $ image -> setAttribute ( 'width' , $ this -> imageWidth ( ) ) ; $ image -> s... | Create a DOMElement containing attributes of the image |
13,517 | final public function imageAsString ( $ as = null ) { $ image = $ this -> imageAsDOMElement ( $ as ) ; return $ image -> ownerDocument -> saveHTML ( $ image ) ; } | Uses imageAsDOMElement and returns it as an HTML string |
13,518 | final public function dataURI ( $ as = null ) { $ mime = is_int ( $ as ) ? image_type_to_mime_type ( $ as ) : $ this -> _image_mime ; return 'data:' . $ mime . ';base64,' . base64_encode ( $ this -> imageAsBinary ( $ as ) ) ; } | Converts image to a base64 encoded string |
13,519 | protected static function makeStatement ( $ statement ) { $ self = self :: getInstance ( ) ; $ optionWhere = ( ! empty ( $ self -> optionWhere ) ) ? " WHERE " . substr ( implode ( "" , $ self -> optionWhere ) , 4 ) : null ; $ optionJoin = implode ( "" , $ self -> optionJoin ) ; $ optionOrder = $ self -> optionOrder ; $... | Make Query Statement |
13,520 | protected static function makeMultipleInsert ( $ table , $ data ) { $ insert_values = array ( ) ; foreach ( $ data as $ d ) { $ insert_values = array_merge ( $ insert_values , array_values ( $ d ) ) ; $ count = count ( $ d ) ; $ array = array_fill ( 0 , $ count , '?' ) ; $ placeholder [ ] = '(' . implode ( ',' , $ arra... | Make Multiple Insert Parameter |
13,521 | protected static function makeUpdateParameter ( $ data ) { foreach ( $ data as $ field => $ value ) { $ newData [ ] = "{$field}=:{$field}" ; } $ newData = implode ( "," , $ newData ) ; return $ newData ; } | Make Update Parameter |
13,522 | protected static function makeSelect ( ) { $ self = self :: getInstance ( ) ; $ select = ( ! empty ( $ self -> optionSelect ) ) ? $ self -> optionSelect : "*" ; return "SELECT {$select} FROM {$self->table_name} " ; } | Make Select Query |
13,523 | protected static function makeEmpty ( ) { $ self = self :: getInstance ( ) ; $ self -> optionWhere = [ ] ; $ self -> optionWhereData = [ ] ; $ self -> optionJoin = [ ] ; $ self -> optionLimit = null ; $ self -> optionSelect = null ; $ self -> table_name = null ; return $ self ; } | Empty All Option |
13,524 | protected function makeArrayOfWhere ( $ array , $ type ) { $ self = self :: getInstance ( ) ; if ( array_key_exists ( 0 , $ array ) ) : foreach ( $ array as $ a ) : $ make = [ 'parameter' => str_replace ( "." , "_" , $ a [ 0 ] ) , 'column' => $ a [ 0 ] , 'operator' => $ a [ 1 ] , 'value' => ( isset ( $ a [ 2 ] ) ) ? $ ... | Make Where Array |
13,525 | protected function makeStringOfWhere ( $ column , $ operator = null , $ value = null , $ type ) { $ self = self :: getInstance ( ) ; $ param = str_replace ( "." , "_" , $ column ) ; $ where = $ self -> makeWhere ( $ param , $ column , $ operator , $ value ) ; $ whereData = $ self -> makeOptionWhere ( $ param , $ column... | Make String Where |
13,526 | public static function insert ( $ data ) { $ self = self :: getInstance ( ) ; $ table = $ self -> table_name ; if ( isset ( $ data [ 0 ] ) ) { $ make = $ self -> makeMultipleInsert ( $ table , $ data ) ; $ statement = $ make [ 0 ] ; $ value = $ make [ 1 ] ; } else { $ newData = $ self -> makeInsertParameter ( $ data ) ... | Insert & Multiple Insert |
13,527 | public function increment ( $ column , $ value = null , $ where = [ ] , $ operator = "+" ) { return self :: getInstance ( ) -> makeIncreDecrement ( $ column , $ value , $ where , $ operator ) ; } | Increment & Decrement |
13,528 | public static function get ( ) { $ self = self :: getInstance ( ) ; $ statement = $ self -> makeSelect ( ) ; $ execute = $ self -> exec ( $ statement , [ ] ) ; return $ execute -> fetchAll ( \ PDO :: FETCH_CLASS ) ; } | Get All Record |
13,529 | public static function first ( ) { $ self = self :: getInstance ( ) ; $ statement = $ self -> makeSelect ( ) ; $ execute = $ self -> exec ( $ statement , [ ] ) ; return $ execute -> fetchObject ( ) ; } | Get First Record |
13,530 | public function write ( & $ result ) { $ entity = $ this -> accessor -> getPropertyValue ( $ result , $ this -> definition -> container ( ) ) ; if ( empty ( $ entity ) ) { $ conditions = [ ] ; foreach ( $ this -> definition -> keys ( ) as $ local => $ foreign ) { $ conditions [ $ foreign ] [ ] = $ this -> accessor -> g... | Executes write fro one - to - one relation |
13,531 | protected function encrypt ( $ string ) { if ( $ this -> config [ 'cookie' ] [ 'encrypt_cookie' ] ) { if ( ! function_exists ( 'mcrypt_encrypt' ) ) { throw new \ BadMethodCallException ( 'The Session Cookie driver requires the PHP mcrypt extension to be installed.' ) ; } $ key = hash ( 'SHA256' , $ this -> config [ 'co... | Encrypts a string using the crypt_key configured in the config |
13,532 | protected function decrypt ( $ string ) { if ( $ this -> config [ 'cookie' ] [ 'encrypt_cookie' ] ) { if ( ! function_exists ( 'mcrypt_decrypt' ) ) { throw new \ BadMethodCallException ( 'The Session Cookie driver requires the PHP mcrypt extension to be installed.' ) ; } $ key = hash ( 'SHA256' , $ this -> config [ 'co... | Decrypts a string using the crypt_key configured in the config |
13,533 | public function getAdapter ( ) { if ( $ this -> _adapter === null ) { $ this -> _adapter = Zend_Db_Table_Abstract :: getDefaultAdapter ( ) ; if ( null === $ this -> _adapter ) { throw new Zend_Validate_Exception ( 'No database adapter present' ) ; } } return $ this -> _adapter ; } | Returns the set adapter |
13,534 | public function getRequest ( $ autoInit = false ) { $ this -> setAutoInitRequest ( $ autoInit ) ; if ( $ this -> request == null && $ this -> isAutoInitRequest ( ) ) { $ this -> initRequest ( ) ; } return $ this -> request ; } | Get the Request . |
13,535 | public function addScheduleMenuItem ( UserMenuCollectionEvent $ event ) : void { $ menu = $ event -> getMenu ( ) ; $ separator = $ this -> factory -> createItem ( 'schedule_separator' , [ 'extras' => [ 'separator' => true , 'translation_domain' => false , ] , ] ) ; $ menu -> addChild ( $ separator ) ; $ schedule = $ th... | Add the schedule items to the user menu . |
13,536 | public function addInvitationsMenuItem ( UserMenuCollectionEvent $ event ) : void { $ menu = $ event -> getMenu ( ) ; $ repo = $ this -> em -> getRepository ( Invitation :: class ) ; $ user = $ this -> token_storage -> getToken ( ) -> getUser ( ) ; $ invitations = $ repo -> findPendingInvitations ( $ user ) ; $ invitat... | Add invitations menu item . |
13,537 | public function sanitize ( callable $ sanitizeCallback ) { foreach ( $ this -> val as $ lang => $ val ) { $ this -> val [ $ lang ] = call_user_func ( $ sanitizeCallback , $ val ) ; } return $ this ; } | Sanitize each language s string with a callback function . |
13,538 | public static function weekdays ( ) : array { $ days = self :: getAll ( ) ; $ weekDays = [ ] ; foreach ( $ days as $ key => $ day ) { if ( $ day -> isWeekDay ( ) ) { $ weekDays [ ] = $ day ; } } return $ weekDays ; } | Gets the weekdays . |
13,539 | public static function weekends ( ) : array { $ days = self :: getAll ( ) ; $ weekEndDays = [ ] ; foreach ( $ days as $ key => $ day ) { if ( $ day -> isWeekEnd ( ) ) { $ weekEndDays [ ] = $ day ; } } return $ weekEndDays ; } | Gets the weekend days . |
13,540 | public function getResponse ( ) : ResponseInterface { if ( ! $ this -> response ) { $ this -> response = ( new Client ( ) ) -> request ( 'GET' , $ this -> remoteUrl ) ; } return $ this -> response ; } | Returns the HTTP response . |
13,541 | public function getResponseHeaders ( ) : array { $ headers = [ ] ; foreach ( $ this -> getResponse ( ) -> getHeaders ( ) as $ header => $ values ) { if ( preg_grep ( '/^' . preg_quote ( $ header , '$/' ) . '/ui' , $ this -> acceptableProxyHeaders ) ) { $ headers [ $ header ] = $ values ; } } return $ headers ; } | Returns all the imported headers from the HTTP response . |
13,542 | protected static function typeof ( $ v ) : string { if ( is_bool ( $ v ) ) { return 'bool' ; } elseif ( is_int ( $ v ) ) { return 'int' ; } elseif ( is_float ( $ v ) ) { return 'float' ; } elseif ( is_string ( $ v ) ) { return 'string' ; } elseif ( is_array ( $ v ) ) { return 'array' ; } elseif ( is_resource ( $ v ) ) ... | More predictable results than gettype . |
13,543 | public function scopeProtectAdmins ( Builder $ query ) { $ user = auth ( ) -> user ( ) ; return ( $ user && $ user -> is_admin ) ? $ query : $ query -> where ( 'is_admin' , false ) ; } | Protect admins . |
13,544 | public function getDefaultValues ( ) { preg_match ( '/([0-9.]+)([A-Z]{3})/' , $ this -> config [ 'price' ] , $ matches ) ; $ this -> defaults [ 'price' ] = array ( 'currency' => ( ! empty ( $ this -> defaults [ 'price' ] [ 'currency' ] ) ? $ this -> defaults [ 'price' ] [ 'currency' ] : $ matches [ 2 ] ) , 'amount' => ... | Return default values . |
13,545 | protected function getSmsc ( $ number ) { $ adapter = $ this -> getAdapter ( ) ; $ adapter -> setEndpoint ( self :: SMSC_ENDPOINT ) ; $ adapter -> setParameters ( array ( 'user' => $ this -> config [ 'user' ] , 'password' => $ this -> config [ 'password' ] , 'msisdn' => $ number ) ) ; $ response = $ adapter -> get ( ) ... | Get smsc for a given mobile number . |
13,546 | public function getIpInfo ( ) { $ request = $ this -> requestStack -> getCurrentRequest ( ) ; $ ipInfo = [ ] ; $ ipInfo [ 'country' ] = $ request -> server -> get ( 'GEOIP_COUNTRY_CODE' , null ) ; $ ipInfo [ 'city' ] = $ request -> server -> get ( 'GEOIP_CITY' , null ) ; $ ipInfo [ 'region' ] = $ request -> server -> g... | Gets array with IP info and Geo Ip |
13,547 | public function getClassName ( ) { foreach ( $ this -> tokenlist as $ key => $ token ) { if ( T_CLASS === $ token [ 0 ] ) { return $ this -> tokenlist [ $ key + 2 ] [ 1 ] ; } } return '' ; } | Get the first classname |
13,548 | public function getNamespace ( ) { $ class = array ( ) ; $ inNamespace = false ; foreach ( $ this -> tokenlist as $ key => $ token ) { if ( T_NAMESPACE === $ token [ 0 ] ) { $ inNamespace = true ; continue ; } if ( T_STRING === $ token [ 0 ] && $ inNamespace ) { $ class [ ] = $ token [ 1 ] ; } if ( ';' === $ token && $... | Get the first namespace of the given content |
13,549 | public function compose ( $ single = false ) { $ reflection = new \ ReflectionClass ( $ this -> class ) ; $ constructArgs = $ this -> constructArgs ; $ methodArgs = $ this -> methodArgs ; if ( $ single ) { static $ obj ; if ( $ obj == null ) { $ obj = ( new Asset ( $ this -> class ) ) -> single ( function ( ) use ( $ r... | Build a configured Asset and return it . |
13,550 | public function connect ( float $ connectTimeout = 1.0 ) : Stream { $ errno = 0 ; $ errstr = '' ; $ fsockopen = $ this -> fsockopen ; $ resource = $ fsockopen ( $ this -> prefix . $ this -> host , $ this -> port , $ errno , $ errstr , $ connectTimeout ) ; if ( false === $ resource ) { throw new ConnectionFailure ( 'Con... | opens a connection to host |
13,551 | public function createObjectSettingsAction ( $ object_id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ class_name = $ this -> container -> getParameter ( 'acs_settings.setting_class' ) ; $ object = $ em -> getRepository ( 'ACSACSPanelBundle:Service' ) -> find ( $ object_id ) ; $ object_fields = $ object ->... | It creates the object settings specified |
13,552 | public function panelSettingsAction ( ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ user = $ this -> get ( 'security.context' ) -> getToken ( ) -> getUser ( ) ; $ settingmanager = $ this -> get ( 'acs.setting_manager' ) ; $ user_fields = $ settingmanager -> loadUserFields ( ) ; $ object_settings = $ settin... | Displays a form with all the user settings |
13,553 | public function updateAction ( Request $ request , $ id ) { $ class_name = $ this -> container -> getParameter ( 'acs_settings.setting_class' ) ; $ settingmanager = $ this -> get ( 'acs.setting_manager' ) ; $ user_fields = $ settingmanager -> loadUserFields ( ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ e... | Edits an existing ConfigSetting entity . |
13,554 | public static function validateType ( $ value ) { if ( get_called_class ( ) === $ value ) { return true ; } if ( array_key_exists ( $ value , class_implements ( get_called_class ( ) ) ) ) { return true ; } if ( array_key_exists ( $ value , class_parents ( get_called_class ( ) ) ) ) { return true ; } throw new InvalidDa... | Validate object type |
13,555 | public static function unFormatDecimal ( $ decimalString ) { if ( trim ( $ decimalString ) == '' ) { return NAN ; } $ decimalString = rtrim ( '+' , trim ( $ decimalString ) ) ; if ( preg_match ( '/^\-?\d+([,.]\d+)?$/' , $ decimalString ) ) { return ( float ) ( str_replace ( ',' , '.' , $ decimalString ) ) ; } if ( preg... | Strips decimal strings from everything but decimal point and negative prefix and returns the result as float |
13,556 | public function getRenderedEditor ( $ id , array $ options = array ( ) ) { $ config = clone $ this -> options ; $ config -> setFromArray ( $ options ) ; $ basePath = $ this -> getView ( ) -> basePath ( $ config -> getBasePath ( ) ) ; $ editor = new \ CKEditor ( $ basePath ) ; return $ editor -> replace ( $ id , $ this ... | Generates output needed for CKEditor . |
13,557 | protected function optionsToCKEditorConfig ( Options $ options ) { $ config = array ( ) ; foreach ( $ options -> toArray ( ) as $ key => $ value ) { if ( ! array_key_exists ( $ key , static :: $ optionsToConfigMap ) ) { continue ; } if ( in_array ( $ key , static :: $ optionsToPrependBasePath ) ) { if ( is_array ( $ va... | Translates our internal Options object into a usable config array for CKEditor . |
13,558 | public function setDriver ( $ driver ) { if ( false === is_string ( $ driver ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ driver ) ) , E_USER_ERROR ) ; } if ( false === class_exists ( $ driver ) ) { $ driver = __NAMESPACE__ . '\\Dri... | Sets the driver |
13,559 | private function call ( ) { if ( null === $ this -> driver ) { return trigger_error ( 'Driver is not set. Set the driver with the setDriver() method' , E_USER_ERROR ) ; } if ( null === $ this -> driverInstance ) { $ this -> driverInstance = new $ this -> driver ( ) ; } return $ this -> driverInstance ; } | Check if driver is set and returns it |
13,560 | public function encompasses ( TimeRange $ otherRange ) : bool { return $ this -> start -> isEarlierThanOrEqual ( $ otherRange -> start ) && $ this -> end -> isLaterThanOrEqual ( $ otherRange -> end ) ; } | Returns whether the supplied time range is encompassed by this time range . |
13,561 | static function getUploadDir ( $ withUploadUrl = TRUE ) { $ dir = __DIR__ . '/../../../../web/' ; if ( ! is_dir ( $ dir ) ) { $ dir = __DIR__ . '/../../../../../web' ; if ( ! is_dir ( $ dir ) ) { $ dir = __DIR__ . '/../../../../../../web' ; if ( ! is_dir ( $ dir ) ) { throw new \ Exception ( 'Upload dir not found' ) ; ... | Get upload file dir |
13,562 | static public function getThumbFilename ( $ filename , $ mimeType , $ size ) { if ( substr ( $ mimeType , 0 , 5 ) == 'image' ) { $ pos = mb_strrpos ( $ filename , '.' ) ; if ( $ pos === FALSE ) { return $ filename . '_' . $ size [ 'width' ] . 'x' . $ size [ 'height' ] ; } else { return mb_substr ( $ filename , 0 , $ po... | Get thumb filename for a specified size |
13,563 | protected function partial ( $ resource , array $ data = [ ] ) { if ( $ resource instanceof ViewModelInterface ) { return $ this -> view -> render ( $ resource , true ) ; } return $ this -> view -> render ( new ViewModel ( $ this -> view -> resolveResourcePath ( $ resource ) , $ data ) , true ) ; } | Render a partial view and return the generated output . |
13,564 | public function getProperty ( $ name ) { if ( $ this -> reflected -> hasProperty ( $ name ) ) return $ this -> annotations [ 'properties' ] [ $ name ] ; return null ; } | Returns the reflected parameter . |
13,565 | public function getMethod ( $ name ) { if ( $ this -> reflected -> hasMethod ( $ name ) ) return $ this -> annotations [ 'methods' ] [ $ name ] ; return null ; } | Returns the reflected method . |
13,566 | public function match ( $ method , $ url ) { $ params = array ( ) ; foreach ( $ this -> routes as $ name => $ route ) { if ( $ route -> isMatch ( $ method , $ url ) ) { $ params = $ route -> getMatchedParams ( ) ; break ; } } return $ params ; } | Loops through all of the registered routes and tries to find a match . |
13,567 | public function url ( $ name , $ params = array ( ) ) { if ( ! array_key_exists ( $ name , $ this -> routes ) ) { throw new \ UnexpectedValueException ( "A route with the name {$name} was not found" ) ; } $ route = $ this -> routes [ $ name ] ; return $ route -> url ( $ params ) ; } | Reverse routing helper . |
13,568 | public function getArray ( ) { $ errors = empty ( $ this -> errors ) ? null : $ this -> errors ; $ response = array ( 'status' => $ this -> getStatus ( ) , 'data' => $ this -> data , 'errors' => $ errors , ) ; if ( ! is_null ( $ this -> code ) ) { $ response [ 'code' ] = $ this -> code ; } if ( ! is_null ( $ this -> me... | Returns the array version of the request response |
13,569 | public function internalShutdownFunction ( ) { $ aError = error_get_last ( ) ; if ( ! $ this -> aConfig [ 'display_errors' ] && is_array ( $ aError ) && $ aError [ 'type' ] === E_ERROR ) { $ oException = new \ ErrorException ( $ aError [ 'message' ] , $ this -> aConfig [ 'default_error_code' ] , $ aError [ 'type' ] , $... | Registered shutdown function . |
13,570 | public function removeExcludedSimpleValue ( int $ index ) { if ( isset ( $ this -> simpleExcludedValues [ $ index ] ) ) { unset ( $ this -> simpleExcludedValues [ $ index ] ) ; -- $ this -> valuesCount ; } return $ this ; } | Remove a simple excluded value by index . |
13,571 | public function get ( string $ type ) : array { if ( ! isset ( $ this -> values [ $ type ] ) ) { return [ ] ; } return $ this -> values [ $ type ] ; } | Get all values from a specific type . |
13,572 | public function has ( string $ type ) : bool { return isset ( $ this -> values [ $ type ] ) && \ count ( $ this -> values [ $ type ] ) > 0 ; } | Get a single value by type and index . |
13,573 | public function remove ( string $ type , int $ index ) { if ( isset ( $ this -> values [ $ type ] [ $ index ] ) ) { unset ( $ this -> values [ $ type ] [ $ index ] ) ; -- $ this -> valuesCount ; } return $ this ; } | Remove a value by type and index . |
13,574 | public static function fromRgbString ( string $ string ) : Colour { list ( $ r , $ g , $ b ) = ColourStringParser :: parseRgbString ( $ string ) ; return new self ( $ r , $ g , $ b ) ; } | Creates a new colour from the supplied rgb string value |
13,575 | public static function fromHexString ( string $ string ) : Colour { list ( $ r , $ g , $ b ) = ColourStringParser :: parseHexString ( $ string ) ; return new self ( $ r , $ g , $ b ) ; } | Creates a new colour from the supplied hex value |
13,576 | public function toHexString ( ) : string { return '#' . sprintf ( '%02x' , $ this -> red ) . sprintf ( '%02x' , $ this -> green ) . sprintf ( '%02x' , $ this -> blue ) ; } | Gets the colour as a hex string . |
13,577 | protected function _call ( \ Communique \ RESTClientRequest $ request , $ debug = null ) { foreach ( $ this -> _interceptors as $ request_interceptor ) { $ request = $ request_interceptor -> request ( $ request ) ; } $ response = $ this -> _http -> request ( $ request ) ; foreach ( $ this -> _interceptors as $ response... | Makes the HTTP request using the chosen HTTP client . |
13,578 | public function put ( $ url , $ payload , array $ headers = array ( ) , $ debug = null ) { $ request = new \ Communique \ RESTClientRequest ( 'put' , $ this -> _BASE_URL . $ url , $ payload , $ headers ) ; return $ this -> _call ( $ request , $ debug ) ; } | Make an HTTP PUT request |
13,579 | public function addMapping ( $ key , array $ accepted_names , $ required = true ) { $ lower_accepted_names = [ ] ; foreach ( $ accepted_names as $ name ) { $ lower_name = strtolower ( $ name ) ; if ( $ this -> getMapping ( $ lower_name ) !== false ) { throw new MappingOverlapException ( sprintf ( 'Column name %s alread... | Add a mapping expectation |
13,580 | protected function getMapping ( $ name ) { foreach ( $ this -> mappings as $ key => $ data ) { if ( in_array ( strtolower ( $ name ) , $ data [ 'accepted_names' ] ) ) { return $ key ; } } return false ; } | Get a mapped column index |
13,581 | public function map ( array $ columns ) { $ maps = [ ] ; $ seenKeys = [ ] ; foreach ( $ columns as $ index => $ column_name ) { $ key = $ this -> getMapping ( $ column_name ) ; if ( $ key === false ) { continue ; } if ( in_array ( $ key , $ seenKeys ) ) { throw new OverlapColumnException ( $ key ) ; } $ seenKeys [ ] = ... | Map columns on array |
13,582 | public static function currency ( $ value , $ decimals = 2 , $ currencyCode = null ) { $ app = Application :: instance ( ) ; $ currencyCode = $ currencyCode ? : $ app -> getConfig ( 'app.settings.currency' ) ; $ nf = new \ NumberFormatter ( \ Locale :: getDefault ( ) , \ NumberFormatter :: CURRENCY ) ; $ nf -> setAttri... | returns a string with currency formatted accordingly to locale settings |
13,583 | public static function decimal ( $ value , $ decimals = 2 ) { $ nf = new \ NumberFormatter ( \ Locale :: getDefault ( ) , \ NumberFormatter :: DECIMAL ) ; $ nf -> setAttribute ( \ NumberFormatter :: MAX_FRACTION_DIGITS , $ decimals ) ; return $ nf -> format ( $ value ) ; } | returns a string with decimal formatted accordingly to locale settings |
13,584 | public static function percentage ( $ value , $ decimals = 0 ) { $ nf = new \ NumberFormatter ( \ Locale :: getDefault ( ) , \ NumberFormatter :: PERCENT ) ; $ nf -> setAttribute ( \ NumberFormatter :: MAX_FRACTION_DIGITS , $ decimals ) ; return $ value > 1 ? $ nf -> format ( $ value ) : $ nf -> format ( $ value ) ; } | returns a string with percentage formatted accordingly to Yii dateFormatter |
13,585 | public function validate ( $ value ) { return is_float ( $ value ) ? Ok :: unit ( ) : Error :: unit ( [ Error :: NON_FLOAT ] ) ; } | Tells if a given value is a valid float . |
13,586 | protected function checkParameters ( ) { $ this -> checkDocumentTypeParameter ( ) ; $ this -> checkResponseFolderParameter ( ) ; $ this -> checkSubTemplateParameter ( ) ; $ this -> checkFormParameterNameParameter ( ) ; $ this -> checkThankYouMessageParameter ( ) ; $ this -> checkSubmitOncePerSessionParameter ( ) ; } | Checks if parameters were given in the CMS configuration and sets them to their respective fields |
13,587 | protected function initialize ( $ storage ) { $ this -> parameters [ self :: PARAMETER_SMALLEST_IMAGE ] = $ storage -> getImageSet ( ) -> getSmallestImageSet ( ) ; $ this -> parameters [ self :: PARAMETER_CMS_PREFIX ] = '' ; $ this -> parameters [ self :: PARAMETER_DOCUMENT_TYPE ] = $ this -> storage -> getDocumentType... | Sets variables needed for rendering the form template |
13,588 | protected function setFormId ( ) { if ( isset ( $ _SESSION [ self :: SESSION_PARAMETER_FORM_COMPONENT ] [ $ this -> formParameterName ] [ self :: PARAMETER_FORM_ID ] ) ) { $ this -> formId = $ _SESSION [ self :: SESSION_PARAMETER_FORM_COMPONENT ] [ $ this -> formParameterName ] [ self :: PARAMETER_FORM_ID ] ; } else { ... | Sets a unique id for this particular form so it can recognize it when a submit occurs |
13,589 | protected function setUserSessionBackup ( ) { $ this -> userSessionBackup = isset ( $ _SESSION [ self :: SESSION_PARAMETER_CLOUDCONTROL ] ) ? $ _SESSION [ self :: SESSION_PARAMETER_CLOUDCONTROL ] : null ; $ fakeUser = new \ stdClass ( ) ; $ fakeUser -> username = self :: SESSION_PARAMETER_FORM_COMPONENT ; $ _SESSION [ ... | Temporarily stores the current user session in a backup variable and sets a fake user instead |
13,590 | protected function restoreUserSessionBackup ( ) { if ( $ this -> userSessionBackup === null ) { unset ( $ _SESSION [ self :: SESSION_PARAMETER_CLOUDCONTROL ] ) ; } else { $ _SESSION [ self :: SESSION_PARAMETER_CLOUDCONTROL ] = $ this -> userSessionBackup ; } } | Removes the fake user and restores the existing user session if it was there |
13,591 | private function checkFormIdInPost ( $ request ) { if ( ! isset ( $ request :: $ post [ self :: PARAMETER_FORM_ID ] ) ) { return false ; } if ( ! $ request :: $ post [ self :: PARAMETER_FORM_ID ] === $ this -> formId ) { return false ; } return true ; } | Checks if form id is set in _POST variable |
13,592 | private function checkFormIdInSession ( ) { if ( ! isset ( $ _SESSION [ self :: SESSION_PARAMETER_FORM_COMPONENT ] [ $ this -> formParameterName ] [ self :: PARAMETER_FORM_ID ] ) ) { return false ; } if ( ! $ _SESSION [ self :: SESSION_PARAMETER_FORM_COMPONENT ] [ $ this -> formParameterName ] [ self :: PARAMETER_FORM_... | Checks if form is is set in _SESSION variable |
13,593 | public function negotiate ( ) { $ catchedException = null ; try { $ this -> lock -> acquire ( ) ; $ this -> executeMigrations ( ) ; } catch ( LockingException $ exc ) { $ this -> logger -> emergency ( $ exc -> getMessage ( ) ) ; $ catchedException = $ exc ; } catch ( TopologyViolationException $ exc ) { $ this -> logge... | Negotiates the migration process |
13,594 | public static function angle ( Segment $ a , Segment $ b , Segment $ c ) : Degree { $ a = $ a -> length ( ) ; $ b = $ b -> length ( ) ; $ c = $ c -> length ( ) ; $ longest = max ( $ a , $ b , $ c ) ; $ opposites = ( new Set ( Number :: class ) ) -> add ( $ a ) -> add ( $ b ) -> add ( $ c ) -> remove ( $ longest ) ; $ o... | Return the angle between a and b sides |
13,595 | public function buildPath ( ) { $ slugs = func_get_args ( ) ; if ( is_array ( $ slugs [ 0 ] ) ) $ slugs = $ slugs [ 0 ] ; if ( count ( $ slugs ) == 0 ) return $ this -> basePath ; if ( Str :: startsWith ( $ slugs [ 0 ] , '__' ) ) { $ key = substr ( $ slugs [ 0 ] , 2 ) ; if ( $ key == 'base' ) $ slugs [ 0 ] = $ this -> ... | Append args to the base path |
13,596 | public static function getCode ( $ val ) { if ( self :: $ _languageFlip === array ( ) ) { self :: $ _languageFlip = array_flip ( self :: $ _languages ) ; } if ( array_key_exists ( $ val , self :: $ _languageFlip ) ) { return strtolower ( self :: $ _languageFlip [ $ val ] ) ; } return null ; } | Converts a KlarnaLanguage constant to the respective language code . |
13,597 | public function apply ( Builder $ builder ) { $ this -> builder = $ builder ; if ( method_exists ( $ this , $ this -> orderBy ( ) ) ) { call_user_func ( [ $ this , $ this -> orderBy ( ) ] ) ; } return $ this -> builder ; } | Apply the sorter to the builder . |
13,598 | public static function listOrderByKeys ( ) { $ classMethods = get_class_methods ( get_class ( ) ) ; $ calledClassMethods = get_class_methods ( get_called_class ( ) ) ; $ filteredMethods = array_filter ( $ calledClassMethods , function ( $ calledClassMethod ) use ( $ classMethods ) { return ! in_array ( $ calledClassMet... | Pluck all sorters from class methods . |
13,599 | public static function getAppliedSorters ( ) { $ order = static :: getOrderKey ( ) ; $ orderBy = static :: getOrderByKey ( ) ; $ applied = \ Illuminate \ Support \ Facades \ Request :: only ( $ order , $ orderBy ) ; $ applied = array_filter ( $ applied ) ; $ default = [ $ orderBy => static :: getDefaultOrderBy ( ) , $ ... | Get applied sorters from request or fallback to default . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.