idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
24,000 | protected function encodeHeader ( ) : string { return \ pack ( 'n*' , ... [ $ this -> id , $ this -> getFlags ( ) , \ count ( $ this -> questions ) , \ count ( $ this -> answers ) , $ this -> authorityCount , $ this -> additionalCount ] ) ; } | Encode the message header into it s binary form . |
24,001 | protected function encodeLabel ( string $ label ) : string { $ encoded = '' ; foreach ( \ explode ( '.' , $ label ) as $ part ) { $ encoded .= \ chr ( \ strlen ( $ part ) ) . $ part ; } return $ encoded . "\x00" ; } | Encode a DNS label into it s binary form . |
24,002 | protected function encodeQuestion ( array $ question ) : string { $ encoded = $ this -> encodeLabel ( $ question [ 'host' ] ) ; $ encoded .= \ pack ( 'nn' , $ question [ 'type' ] , $ question [ 'class' ] ) ; return $ encoded ; } | Encode a question record . |
24,003 | protected function encodeAnswer ( array $ answer ) : string { $ encoded = $ this -> encodeLabel ( $ answer [ 'host' ] ) ; switch ( $ answer [ 'type' ] ) { case self :: TYPE_A : case self :: TYPE_AAAA : $ data = \ inet_pton ( $ answer [ 'data' ] ) ; break ; case self :: TYPE_CNAME : $ data = $ this -> encodeLabel ( $ answer [ 'data' ] ) ; break ; default : $ data = $ answer [ 'data' ] ; } $ encoded .= \ pack ( 'nnNn' , $ answer [ 'type' ] , self :: CLASS_IN , $ answer [ 'ttl' ] , \ strlen ( $ data ) ) ; $ encoded .= $ data ; return $ encoded ; } | Encode an answer record . |
24,004 | public function emptycart ( ) { ShoppingCartFactory :: create ( ) -> delete ( ) ; $ form = $ this -> CartForm ( ) ; $ form -> sessionMessage ( _t ( "ShoppingCart.EmptiedCart" , "Shopping cart emptied" ) ) ; return $ this -> redirectBack ( ) ; } | Action that will clear shopping cart and associated items |
24,005 | public function checkout ( ) { if ( ! class_exists ( $ this -> config ( ) -> checkout_class ) ) { return $ this -> httpError ( 404 ) ; } $ checkout = Injector :: inst ( ) -> get ( $ this -> config ( ) -> checkout_class ) ; $ checkout -> setEstimate ( $ this -> dataRecord ) ; $ this -> extend ( "onBeforeCheckout" ) ; $ this -> redirect ( $ checkout -> Link ( ) ) ; } | Setup the checkout and redirect to it |
24,006 | public function getFormat ( string $ dateLength ) : string { if ( false === ( new DateLength ( ) ) -> isCorrectType ( $ dateLength ) ) { throw UnknownDateLengthException :: createException ( $ dateLength ) ; } $ format = '' ; switch ( $ dateLength ) { case DateLength :: DATE : $ format = $ this -> dateFormat ; break ; case DateLength :: DATETIME : $ format = $ this -> dateTimeFormat ; break ; case DateLength :: TIME : $ format = $ this -> timeFormat ; break ; } return $ format ; } | Returns format of date according to given length of date |
24,007 | public function formatDate ( \ DateTimeInterface $ dateTime , string $ dateLength ) : string { $ format = $ this -> getFormat ( $ dateLength ) ; return $ dateTime -> format ( $ format ) ; } | Returns date formatted according to given length of date |
24,008 | public function success ( int $ statusCode , string $ message , $ data = null ) : JsonResponse { $ this -> setStatusCode ( $ statusCode ) ; $ this -> setMessage ( $ message ) ; $ this -> setData ( $ data ) ; $ content [ 'message' ] = $ this -> getMessage ( ) ; if ( null !== $ this -> getCode ( ) ) { $ content [ 'code' ] = $ this -> getCode ( ) ; } $ content [ 'status_code' ] = $ this -> getStatusCode ( ) ; if ( null !== $ this -> getData ( ) && $ this -> getErrors ( ) !== $ this -> getData ( ) ) { $ content [ 'data' ] = $ this -> getData ( ) ; } if ( null !== $ this -> getErrors ( ) ) { $ content [ 'errors' ] = $ this -> getErrors ( ) ; } $ content += $ this -> Hypermedia ; return new JsonResponse ( $ content , $ this -> getHttpStatusCode ( ) ? : $ this -> getStatusCode ( ) ) ; } | Public Success Method . |
24,009 | private function explodeChildren ( $ id , array $ childrenMap ) { if ( ! isset ( $ childrenMap [ $ id ] ) ) { return [ ] ; } $ indexed = [ ] ; foreach ( $ childrenMap [ $ id ] as $ childName ) { $ indexed [ $ childName ] = $ childName ; } return array_map ( function ( $ childId ) use ( $ childrenMap ) { return $ this -> explodeChildren ( $ childId , $ childrenMap ) ; } , $ indexed ) ; } | Retrieves all children of a given element recursively Must be given a childrenMap for performance reasons |
24,010 | protected function doHydrate ( array $ data , $ object ) { $ previousHydrationContext = $ this -> currentHydrationContext ; $ this -> currentHydrationContext = new CurrentHydrationContext ( $ data , $ object ) ; foreach ( $ this -> metadata -> getMappedFieldNames ( ) as $ mappedFieldName ) { $ defaultValue = $ this -> metadata -> getFieldDefaultValue ( $ mappedFieldName ) ; if ( null !== $ defaultValue ) { $ this -> resolveValue ( $ defaultValue , $ object ) ; $ this -> memberAccessStrategy -> setValue ( $ defaultValue , $ object , $ mappedFieldName ) ; } } if ( ! $ this -> metadata -> hasCustomHydrator ( ) ) { $ this -> executeMethods ( $ object , $ this -> metadata -> getPreHydrateListeners ( ) ) ; foreach ( $ data as $ originalFieldName => $ value ) { $ mappedFieldName = $ this -> metadata -> getMappedFieldName ( $ originalFieldName ) ; if ( null === $ mappedFieldName ) { continue ; } if ( ! $ this -> metadata -> hasSource ( $ mappedFieldName ) ) { $ this -> walkHydration ( $ mappedFieldName , $ object , $ value , $ data ) ; } } } else { list ( $ customHydratorClass , $ customHydrateMethod ) = $ this -> metadata -> getCustomHydratorInfo ( ) ; $ this -> executeMethod ( $ object , new ClassMetadata \ Model \ Method ( $ customHydratorClass , $ customHydrateMethod , [ $ data , $ object ] ) ) ; } foreach ( $ this -> metadata -> getFieldsWithDataSources ( ) as $ mappedFieldName ) { if ( $ this -> metadata -> hasDataSource ( $ mappedFieldName ) ) { $ this -> walkHydrationByDataSource ( $ mappedFieldName , $ object , false ) ; } } foreach ( $ this -> metadata -> getFieldsWithProviders ( ) as $ mappedFieldName ) { if ( $ this -> metadata -> hasProvider ( $ mappedFieldName ) ) { $ this -> walkHydrationByProvider ( $ mappedFieldName , $ object , false ) ; } } foreach ( $ this -> metadata -> getFieldsWithValueObjects ( ) as $ mappedFieldName ) { $ this -> walkValueObjectHydration ( $ mappedFieldName , $ object , $ data ) ; } $ this -> executeMethods ( $ object , $ this -> metadata -> getPostHydrateListeners ( ) ) ; $ this -> currentHydrationContext = $ previousHydrationContext ; return $ object ; } | Hydrate an object from data . |
24,011 | public function getCurrentConfigVariableByName ( $ variableKey ) { if ( ! isset ( $ this -> currentConfigVariables [ $ variableKey ] ) ) { throw new ObjectMappingException ( sprintf ( 'The current config variables do not contains key "%s". Availables keys are "[%s]".' , $ variableKey , implode ( ',' , array_keys ( $ this -> currentConfigVariables ) ) ) ) ; } return $ this -> currentConfigVariables [ $ variableKey ] ; } | Gets all the variables used in a object mapping configuration . |
24,012 | protected function registerReader ( ) { $ this -> app -> when ( AnnotationsReader :: class ) -> needs ( Reader :: class ) -> give ( function ( ) { return $ this -> createAndReturnCachedReader ( ) ; } ) ; } | Registers the Annotations reader . |
24,013 | protected function addAnnotationsToRegistry ( ) { $ reader = $ this -> app -> make ( AnnotationsReader :: class ) ; $ reader -> addFilesToRegistry ( config ( 'pine-annotations.autoload_files' ) ) ; $ reader -> addNamespacesToRegistry ( config ( 'pine-annotations.autoload_namespaces' ) ) ; } | Add files and namespaces to the annotations registry . |
24,014 | public function isDimensionsEqual ( ) { if ( $ this -> image1 -> getImageWidth ( ) !== $ this -> image2 -> getImageWidth ( ) || $ this -> image1 -> getImageHeight ( ) !== $ this -> image2 -> getImageHeight ( ) ) { return FALSE ; } return TRUE ; } | Check if dimensions of images is equal . |
24,015 | public function isEqual ( ) { if ( ! $ this -> isDimensionsEqual ( ) ) { return FALSE ; } $ compare = $ this -> image1 -> compareImages ( $ this -> image2 , Imagick :: METRIC_MEANSQUAREERROR ) ; if ( $ compare === TRUE ) { return TRUE ; } elseif ( $ compare ) { if ( $ compare [ 1 ] < $ this -> tolerance ) { return TRUE ; } } return FALSE ; } | Check if images is exactly the same . |
24,016 | public function createModel ( $ class , $ id ) { $ this -> model = new $ class ( ) ; if ( $ id ) { $ this -> model -> setId ( $ id ) ; } return $ this ; } | Create the Paymill model |
24,017 | public function index ( Request $ request , UserRepository $ users ) { return view ( 'authentication::user.index' ) -> with ( 'users' , $ users -> query ( $ request -> get ( 'q' ) ) ) ; } | Shows the user index . |
24,018 | private static function getAllYamls ( string $ directory ) : \ Generator { foreach ( new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ directory ) ) as $ file ) { if ( $ file -> isFile ( ) && $ file -> getExtension ( ) === 'yml' ) { $ fileName = $ file -> getPathname ( ) ; yield $ fileName => Yaml :: parse ( file_get_contents ( $ fileName ) ) ; } } } | Get the contents of all yaml files in a directory recursively . |
24,019 | public function addVariable ( $ key , $ value ) { if ( is_null ( $ key ) || ! is_string ( $ key ) ) { throw new RuntimeException ( sprintf ( 'The key where to save your variable in the expression context is invalid. Got "%s".' , $ key ) ) ; } $ this -> variables [ $ key ] = $ value ; } | Add a variable in the context . |
24,020 | public function serverResponse ( ) { if ( ! empty ( $ _GET [ 'imageQuery' ] ) ) { $ picture = $ this -> loadPicture ( $ _GET [ 'imageQuery' ] ) ; $ savePath = $ this -> getPath ( $ picture ) ; $ picture -> save ( $ savePath ) ; if ( $ savePath !== $ this -> getPath ( $ picture ) ) { throw new Exception ( 'Picture effect is changing its own arguments on effect apply' ) ; } $ picture -> output ( ) ; } if ( ! empty ( $ _POST [ 'regenerate' ] ) ) { $ picture = $ this -> loadPicture ( $ _POST [ 'regenerate' ] ) ; $ picture -> save ( $ this -> getPath ( $ picture ) ) ; } } | Execute server generator backend . |
24,021 | function requestWithoutWaiting ( $ url , array $ params = array ( ) ) { $ post = array ( ) ; foreach ( $ params as $ index => $ val ) { $ post [ ] = $ index . '=' . urlencode ( $ val ) ; } $ post = implode ( '&' , $ post ) ; $ request = parse_url ( $ url ) ; if ( ! isset ( $ request [ 'host' ] ) ) { $ request [ 'host' ] = $ _SERVER [ 'HTTP_HOST' ] ; } if ( ! isset ( $ request [ 'port' ] ) ) { $ request [ 'port' ] = $ _SERVER [ 'SERVER_PORT' ] ; } $ protocol = isset ( $ _SERVER [ 'HTTPS' ] ) ? 'ssl://' : '' ; $ safePort = isset ( $ _SERVER [ 'HTTPS' ] ) ? 443 : 80 ; if ( $ request [ 'port' ] == 80 && $ safePort == 443 ) { $ request [ 'port' ] = $ safePort ; } $ fp = fsockopen ( $ protocol . $ request [ 'host' ] , $ request [ 'port' ] , $ errNo , $ errStr , 60 ) ; $ command = "POST " . $ request [ 'path' ] . " HTTP/1.1\r\n" ; $ command .= "Host: " . $ request [ 'host' ] . "\r\n" ; $ command .= "Content-Type: application/x-www-form-urlencoded\r\n" ; $ command .= "Content-Length: " . strlen ( $ post ) . "\r\n" ; $ command .= "Connection: Close\r\n\r\n" ; if ( $ post ) { $ command .= $ post ; } fwrite ( $ fp , $ command ) ; fclose ( $ fp ) ; } | Sends the POST request without waiting for a response . |
24,022 | public function setValue ( $ name , $ value ) { $ child = & $ this -> data ; foreach ( $ this -> currentPath as $ part ) { if ( isset ( $ child [ $ part ] ) ) { $ child = & $ child [ $ part ] ; } else { $ child [ $ part ] = [ ] ; $ child = & $ child [ $ part ] ; } } $ child [ $ name ] = $ value ; } | Set a value in the current level . |
24,023 | public function getValue ( $ name ) { $ child = & $ this -> data ; foreach ( $ this -> currentPath as $ part ) { if ( isset ( $ child [ $ part ] ) ) { $ child = & $ child [ $ part ] ; } else { return null ; } } return isset ( $ child [ $ name ] ) ? $ child [ $ name ] : null ; } | Get a value by name from the current level . |
24,024 | public function getValueByPath ( $ path ) { if ( is_string ( $ path ) ) { $ path = $ this -> parsePath ( $ path ) ; } $ child = $ this -> data ; foreach ( $ path as $ part ) { if ( isset ( $ child [ $ part ] ) ) { $ child = $ child [ $ part ] ; } else { return null ; } } return $ child ; } | Find a value by path within the DataSet instance . |
24,025 | public function setValueByPath ( $ path , $ value ) { if ( is_string ( $ path ) ) { $ path = $ this -> parsePath ( $ path ) ; } $ endPart = array_pop ( $ path ) ; $ child = & $ this -> data ; foreach ( $ path as $ part ) { if ( isset ( $ child [ $ part ] ) ) { $ child = & $ child [ $ part ] ; } else { $ child [ $ part ] = [ ] ; $ child = & $ child [ $ part ] ; } } $ child [ $ endPart ] = $ value ; } | Assign a value by path within the DataSet instance overwrites any existing value . |
24,026 | public function parsePath ( $ path ) { $ parts = explode ( '/' , trim ( $ path , '/' ) ) ; $ pathArray = [ ] ; if ( $ parts [ 0 ] == '.' ) { $ pathArray = $ this -> currentPath ; array_shift ( $ parts ) ; } foreach ( $ parts as $ part ) { if ( $ part == '..' ) { if ( count ( $ pathArray ) ) { array_pop ( $ pathArray ) ; } else { throw new Field \ ConfigurationException ( "Invalid path. To many '..', can't move higher root." ) ; } } else { $ pathArray [ ] = $ part ; } } return $ pathArray ; } | Transform human path to internal DataSet format . |
24,027 | public function resolvePath ( $ value ) { do { $ value = $ this -> getValueByPath ( $ value ) ; } while ( self :: isPath ( $ value ) ) ; return $ value ; } | Recursively find value by path . |
24,028 | public function create ( WP_Post $ attachment , Size $ size ) : Source { if ( ! wp_attachment_is_image ( $ attachment ) ) { throw new InvalidArgumentException ( 'Attachment must be an image.' ) ; } $ imageSource = ( array ) wp_get_attachment_image_src ( $ attachment -> ID , [ $ size -> width ( ) , $ size -> height ( ) ] ) ; $ imageSource = array_filter ( $ imageSource ) ; if ( ! $ imageSource ) { throw new DomainException ( sprintf ( 'Image with ID: %d, no longer exists' , $ attachment -> ID ) ) ; } return new Source ( ... $ imageSource ) ; } | Create an Instance of Source by the Given Attachment Post and Size |
24,029 | protected function _doRequest ( $ method , $ uri , $ options ) { if ( isset ( $ options [ self :: OPT_VIDEO_MANAGER_ID ] ) ) { $ options [ 'config' ] [ self :: OPT_VIDEO_MANAGER_ID ] = $ options [ self :: OPT_VIDEO_MANAGER_ID ] ; unset ( $ options [ self :: OPT_VIDEO_MANAGER_ID ] ) ; } $ request = $ this -> httpClient -> createRequest ( $ method , $ uri , $ options ) ; return $ this -> httpClient -> send ( $ request ) ; } | Guzzle5 Client implementation for making HTTP requests with the appropriate options . |
24,030 | private function createManager ( ) { $ config = $ this -> generateConfig ( ) ; $ algoliaManager = $ this -> algoliaFactory -> make ( $ config ) ; $ algoliaManager -> setEnv ( $ this -> env ) ; return $ algoliaManager ; } | Returns a new AlgoliaManager . |
24,031 | private function generateConfig ( ) { return new AlgoliaConfig ( $ this -> applicationId , $ this -> apiKey , $ this -> hostsArray , $ this -> options ) ; } | Generates config for the Algolia Manager . |
24,032 | public static function hasExtension ( string $ uri , string $ extension ) : bool { $ extension = '.' . ltrim ( $ extension , '.' ) ; $ uriLength = mb_strlen ( $ uri ) ; $ extensionLength = mb_strlen ( $ extension ) ; if ( $ extensionLength > $ uriLength ) { return false ; } return substr_compare ( $ uri , $ extension , $ uriLength - $ extensionLength , $ extensionLength ) === 0 ; } | Check whether a given URI has a specific extension . |
24,033 | public static function containsExtension ( string $ uri ) : string { $ pathParts = explode ( '/' , $ uri ) ; $ filename = array_pop ( $ pathParts ) ; $ filenameParts = explode ( '.' , $ filename ) ; if ( count ( $ filenameParts ) > 1 ) { return array_pop ( $ filenameParts ) ; } return '' ; } | Check whether a given URI contains an extension and return it . |
24,034 | private function extractPermissionFrom ( Route $ route ) { $ parameters = $ route -> getAction ( ) ; if ( isset ( $ parameters [ 'permission' ] ) ) { return $ parameters [ 'permission' ] ; } return null ; } | Extracts the permission configured inside the route action array . |
24,035 | protected function getUrlFromRoute ( $ name , Route $ route ) { $ option = $ route -> getOption ( 'sitemap' ) ; if ( $ option === null ) { return null ; } if ( is_string ( $ option ) ) { $ decoded = json_decode ( $ option , true ) ; if ( ! json_last_error ( ) && is_array ( $ decoded ) ) { $ option = $ decoded ; } } if ( ! is_array ( $ option ) && ! is_bool ( $ option ) ) { $ bool = filter_var ( $ option , FILTER_VALIDATE_BOOLEAN , FILTER_NULL_ON_FAILURE ) ; if ( null === $ bool ) { throw new \ InvalidArgumentException ( "The sitemap option for route $name must be boolean or array" ) ; } $ option = $ bool ; } if ( ! $ option ) { return null ; } $ url = $ this -> router -> generate ( $ name ) ; $ urlObject = new Url ( $ url , ( isset ( $ option [ 'lastMod' ] ) ? $ option [ 'lastMod' ] : null ) , ( isset ( $ option [ 'priority' ] ) ? $ option [ 'priority' ] : null ) , ( isset ( $ option [ 'changeFreq' ] ) ? $ option [ 'changeFreq' ] : null ) ) ; return $ urlObject ; } | Create URL object from route annotations |
24,036 | public function getRenderCallback ( string $ uri , array $ context = [ ] ) : callable { if ( ! is_readable ( $ uri ) ) { throw new FailedToLoadView ( sprintf ( _ ( 'The View URI "%1$s" is not accessible or readable.' ) , $ uri ) ) ; } $ closure = function ( ) use ( $ uri , $ context ) { $ bufferLevel = ob_get_level ( ) ; ob_start ( ) ; try { include $ uri ; } catch ( Exception $ exception ) { while ( ob_get_level ( ) > $ bufferLevel ) { ob_end_clean ( ) ; } throw new FailedToLoadView ( sprintf ( _ ( 'Could not load the View URI "%1$s". Reason: "%2$s".' ) , $ uri , $ exception -> getMessage ( ) ) , $ exception -> getCode ( ) , $ exception ) ; } return ob_get_clean ( ) ; } ; return $ closure ; } | Get the rendering callback for a given URI . |
24,037 | public static function createMultiple ( $ number , $ length = 10 , $ type = 'pronounceable' , $ chars = '' ) { $ passwords = array ( ) ; while ( $ number > 0 ) { while ( true ) { $ password = self :: create ( $ length , $ type , $ chars ) ; if ( ! in_array ( $ password , $ passwords ) ) { $ passwords [ ] = $ password ; break ; } } $ number -- ; } return $ passwords ; } | Create multiple different passwords |
24,038 | public static function createMultipleFromLogin ( $ login , $ type , $ key = 0 ) { $ passwords = array ( ) ; $ number = count ( $ login ) ; $ save = $ number ; while ( $ number > 0 ) { while ( true ) { $ password = self :: createFromLogin ( $ login [ $ save - $ number ] , $ type , $ key ) ; if ( ! in_array ( $ password , $ passwords ) ) { $ passwords [ ] = $ password ; break ; } } $ number -- ; } return $ passwords ; } | Create multiple different passwords from an array of login |
24,039 | protected static function _shuffle ( $ login ) { $ tmp = array ( ) ; for ( $ i = 0 ; $ i < strlen ( $ login ) ; $ i ++ ) { $ tmp [ ] = $ login [ $ i ] ; } shuffle ( $ tmp ) ; return implode ( $ tmp , '' ) ; } | Helper method to create password |
24,040 | protected static function _rand ( $ min , $ max ) { if ( version_compare ( PHP_VERSION , '7.0.0' , 'ge' ) ) { $ value = random_int ( $ min , $ max ) ; } else { $ value = mt_rand ( $ min , $ max ) ; } return $ value ; } | Gets a random integer between min and max |
24,041 | public function badRequest ( $ message = 'Bad Request' , $ errors = null ) : void { $ this -> setStatusCode ( 400 ) ; $ this -> setMessage ( $ message ) ; $ this -> setErrors ( $ errors ) ; throw new ApiException ( $ this ) ; } | Client errors - Bad Request |
24,042 | public function finalize ( ) { \ Ease \ TWB \ Part :: twBootstrapize ( ) ; $ this -> includeJavascript ( 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.js' ) ; $ this -> includeCss ( 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.css' ) ; $ this -> addJavascript ( '$(\'#' . $ this -> getTagID ( ) . '\').treeview({' . \ Ease \ TWB \ Part :: partPropertiesToString ( $ this -> properties ) . '})' , null , true ) ; } | Include requied assets in page |
24,043 | public function stream ( $ url , array $ query , callable $ eventListener ) { try { $ response = $ this -> guzzleClient -> request ( 'GET' , $ this -> fullUrl ( $ url ) , $ this -> getRequestOptions ( [ 'stream' => true , 'query' => $ this -> mergeQuery ( $ url , $ query ) , 'headers' => [ 'Accept' => 'text/event-stream' ] ] ) ) ; } catch ( RequestException $ exception ) { if ( $ exception -> hasResponse ( ) ) { $ response = $ exception -> getResponse ( ) ; } else { return 500 ; } } if ( strpos ( $ response -> getHeader ( 'Content-Type' ) [ 0 ] , 'text/event-stream' ) !== false ) { $ this -> handleStreamBody ( $ response -> getBody ( ) , $ eventListener ) ; } elseif ( $ this -> isJsonResponse ( $ response ) ) { $ responseData = $ this -> decodeJson ( $ response -> getBody ( ) ) ; $ eventListener ( [ 'type' => '' , 'id' => '' , 'data' => $ responseData ] ) ; } return $ response -> getStatusCode ( ) ; } | Request object stream |
24,044 | protected function sendRequest ( $ requiredParams , $ params , $ callback ) { $ response = $ this -> client -> send ( $ requiredParams , array_merge ( $ params , [ 'module' => static :: getModule ( ) , 'controller' => static :: getController ( ) , 'version' => $ this -> version , ] ) , function ( $ response ) use ( $ callback ) { if ( isset ( $ response -> error ) ) { return $ response ; } return call_user_func ( $ callback , $ response ) ; } ) ; if ( isset ( $ response -> error ) ) { $ this -> lastError = isset ( $ response -> error -> message ) ? $ response -> error -> message : 'Unknown error!' ; if ( $ this -> client -> softExceptionEnabled ) { if ( isset ( $ response -> meta [ 'statusCode' ] ) ? $ response -> meta [ 'statusCode' ] : false ) { throw $ response -> error -> exception ; } throw new Exception ( 'API error ' . ( isset ( $ response -> error -> code ) ? $ response -> error -> code : - 1 ) . '!' ) ; } } return $ response ; } | Sends the request to the Shardimage API and returns with the Response object or the ID for the request if deferred . |
24,045 | public function mergeEnvironments ( array $ lines , string $ file ) : array { if ( $ this -> files -> exists ( $ file ) ) { $ lines = \ array_replace_recursive ( $ lines , $ this -> files -> getRequire ( $ file ) ) ; } return $ lines ; } | Merge the items in the given file into the items . |
24,046 | public static function getValue ( $ slug , $ featureId , $ locale = 'en_US' ) { return self :: getValues ( [ $ slug ] , [ $ featureId ] , $ locale ) [ $ slug ] [ $ featureId ] ; } | Returns a value based on the slug feature_av_id and locale |
24,047 | protected function _doRequest ( $ method , $ uri , $ options ) { return $ this -> httpClient -> request ( $ method , $ uri , $ options ) ; } | Guzzle6 Client implementation for making HTTP requests with the appropriate options . |
24,048 | protected function loadPage ( $ page ) { $ this -> pageStart = $ page * $ this -> pageSize ; $ this -> pageData = $ this -> query -> setFirstResult ( $ this -> pageStart ) -> setMaxResults ( $ this -> pageSize ) -> getResult ( ) ; } | Load cache page |
24,049 | public function initFeatureFeatureTypes ( $ overrideExisting = true ) { if ( null !== $ this -> collFeatureFeatureTypes && ! $ overrideExisting ) { return ; } $ this -> collFeatureFeatureTypes = new ObjectCollection ( ) ; $ this -> collFeatureFeatureTypes -> setModel ( '\FeatureType\Model\FeatureFeatureType' ) ; } | Initializes the collFeatureFeatureTypes collection . |
24,050 | public function getFeatureFeatureTypes ( $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collFeatureFeatureTypesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collFeatureFeatureTypes || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collFeatureFeatureTypes ) { $ this -> initFeatureFeatureTypes ( ) ; } else { $ collFeatureFeatureTypes = ChildFeatureFeatureTypeQuery :: create ( null , $ criteria ) -> filterByFeatureType ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collFeatureFeatureTypesPartial && count ( $ collFeatureFeatureTypes ) ) { $ this -> initFeatureFeatureTypes ( false ) ; foreach ( $ collFeatureFeatureTypes as $ obj ) { if ( false == $ this -> collFeatureFeatureTypes -> contains ( $ obj ) ) { $ this -> collFeatureFeatureTypes -> append ( $ obj ) ; } } $ this -> collFeatureFeatureTypesPartial = true ; } reset ( $ collFeatureFeatureTypes ) ; return $ collFeatureFeatureTypes ; } if ( $ partial && $ this -> collFeatureFeatureTypes ) { foreach ( $ this -> collFeatureFeatureTypes as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collFeatureFeatureTypes [ ] = $ obj ; } } } $ this -> collFeatureFeatureTypes = $ collFeatureFeatureTypes ; $ this -> collFeatureFeatureTypesPartial = false ; } } return $ this -> collFeatureFeatureTypes ; } | Gets an array of ChildFeatureFeatureType objects which contain a foreign key that references this object . |
24,051 | public function countFeatureFeatureTypes ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collFeatureFeatureTypesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collFeatureFeatureTypes || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collFeatureFeatureTypes ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getFeatureFeatureTypes ( ) ) ; } $ query = ChildFeatureFeatureTypeQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByFeatureType ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collFeatureFeatureTypes ) ; } | Returns the number of related FeatureFeatureType objects . |
24,052 | public function addFeatureFeatureType ( ChildFeatureFeatureType $ l ) { if ( $ this -> collFeatureFeatureTypes === null ) { $ this -> initFeatureFeatureTypes ( ) ; $ this -> collFeatureFeatureTypesPartial = true ; } if ( ! in_array ( $ l , $ this -> collFeatureFeatureTypes -> getArrayCopy ( ) , true ) ) { $ this -> doAddFeatureFeatureType ( $ l ) ; } return $ this ; } | Method called to associate a ChildFeatureFeatureType object to this object through the ChildFeatureFeatureType foreign key attribute . |
24,053 | public function getFeatureFeatureTypesJoinFeature ( $ criteria = null , $ con = null , $ joinBehavior = Criteria :: LEFT_JOIN ) { $ query = ChildFeatureFeatureTypeQuery :: create ( null , $ criteria ) ; $ query -> joinWith ( 'Feature' , $ joinBehavior ) ; return $ this -> getFeatureFeatureTypes ( $ query , $ con ) ; } | If this collection has already been initialized with an identical criteria it returns the collection . Otherwise if this FeatureType is new it will return an empty collection ; or if this FeatureType has previously been saved it will retrieve related FeatureFeatureTypes from storage . |
24,054 | public function initFeatureTypeI18ns ( $ overrideExisting = true ) { if ( null !== $ this -> collFeatureTypeI18ns && ! $ overrideExisting ) { return ; } $ this -> collFeatureTypeI18ns = new ObjectCollection ( ) ; $ this -> collFeatureTypeI18ns -> setModel ( '\FeatureType\Model\FeatureTypeI18n' ) ; } | Initializes the collFeatureTypeI18ns collection . |
24,055 | public function getFeatureTypeI18ns ( $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collFeatureTypeI18nsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collFeatureTypeI18ns || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collFeatureTypeI18ns ) { $ this -> initFeatureTypeI18ns ( ) ; } else { $ collFeatureTypeI18ns = ChildFeatureTypeI18nQuery :: create ( null , $ criteria ) -> filterByFeatureType ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collFeatureTypeI18nsPartial && count ( $ collFeatureTypeI18ns ) ) { $ this -> initFeatureTypeI18ns ( false ) ; foreach ( $ collFeatureTypeI18ns as $ obj ) { if ( false == $ this -> collFeatureTypeI18ns -> contains ( $ obj ) ) { $ this -> collFeatureTypeI18ns -> append ( $ obj ) ; } } $ this -> collFeatureTypeI18nsPartial = true ; } reset ( $ collFeatureTypeI18ns ) ; return $ collFeatureTypeI18ns ; } if ( $ partial && $ this -> collFeatureTypeI18ns ) { foreach ( $ this -> collFeatureTypeI18ns as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collFeatureTypeI18ns [ ] = $ obj ; } } } $ this -> collFeatureTypeI18ns = $ collFeatureTypeI18ns ; $ this -> collFeatureTypeI18nsPartial = false ; } } return $ this -> collFeatureTypeI18ns ; } | Gets an array of ChildFeatureTypeI18n objects which contain a foreign key that references this object . |
24,056 | public function countFeatureTypeI18ns ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collFeatureTypeI18nsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collFeatureTypeI18ns || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collFeatureTypeI18ns ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getFeatureTypeI18ns ( ) ) ; } $ query = ChildFeatureTypeI18nQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByFeatureType ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collFeatureTypeI18ns ) ; } | Returns the number of related FeatureTypeI18n objects . |
24,057 | public function addFeatureTypeI18n ( ChildFeatureTypeI18n $ l ) { if ( $ l && $ locale = $ l -> getLocale ( ) ) { $ this -> setLocale ( $ locale ) ; $ this -> currentTranslations [ $ locale ] = $ l ; } if ( $ this -> collFeatureTypeI18ns === null ) { $ this -> initFeatureTypeI18ns ( ) ; $ this -> collFeatureTypeI18nsPartial = true ; } if ( ! in_array ( $ l , $ this -> collFeatureTypeI18ns -> getArrayCopy ( ) , true ) ) { $ this -> doAddFeatureTypeI18n ( $ l ) ; } return $ this ; } | Method called to associate a ChildFeatureTypeI18n object to this object through the ChildFeatureTypeI18n foreign key attribute . |
24,058 | public function index ( $ params = [ ] , $ optParams = [ ] ) { if ( $ optParams instanceof IndexParams ) { $ optParams = $ optParams -> toArray ( true ) ; } if ( is_string ( $ params ) ) { $ params = [ 'cloudId' => $ params ] ; } return $ this -> sendRequest ( [ 'cloudId' ] , [ 'restAction' => 'index' , 'uri' => '/c/<cloudId>' , 'params' => $ params , 'getParams' => $ optParams , ] , function ( $ response ) use ( $ params ) { $ images = [ ] ; foreach ( $ response -> data [ 'items' ] as $ image ) { if ( ! isset ( $ image [ 'cloudId' ] ) ) { $ image [ 'cloudId' ] = $ this -> client -> getParam ( $ params , 'cloudId' ) ; } $ images [ ] = new Image ( $ image ) ; } return new Index ( [ 'models' => $ images , 'nextPageToken' => $ response -> data [ 'nextPageToken' ] , ] ) ; } ) ; } | Fetches all images . |
24,059 | public function view ( $ params , $ optParams = [ ] ) { if ( is_string ( $ params ) ) { $ params = [ 'publicId' => $ params ] ; } if ( $ optParams instanceof ViewParams ) { $ optParams = $ optParams -> toArray ( true ) ; } return $ this -> sendRequest ( [ 'cloudId' , 'publicId' ] , [ 'restAction' => 'view' , 'uri' => '/c/<cloudId>/o/<publicId>' , 'params' => $ params , 'getParams' => $ optParams , ] , function ( $ response ) use ( $ params ) { if ( $ response -> data && ! isset ( $ response -> data [ 'cloudId' ] ) ) { $ response -> data [ 'cloudId' ] = $ this -> client -> getParam ( $ params , 'cloudId' ) ; } return isset ( $ response -> data ) ? new Image ( $ response -> data ) : $ response ; } ) ; } | Fetches an image . |
24,060 | public function rename ( $ params , $ optParams = [ ] ) { return $ this -> sendRequest ( [ 'cloudId' , 'publicId' , 'newPublicId' ] , [ 'restAction' => 'update' , 'uri' => '/c/<cloudId>/o/<publicId>/rename/o/<newPublicId>' , 'params' => $ params , 'getParams' => $ optParams , ] , function ( $ response ) use ( $ params ) { if ( $ response -> data && ! isset ( $ response -> data [ 'cloudId' ] ) ) { $ response -> data [ 'cloudId' ] = $ this -> client -> getParam ( $ params , 'cloudId' ) ; } return isset ( $ response -> data ) ? new Image ( $ response -> data ) : $ response ; } ) ; } | Renames the ID of an image . |
24,061 | public function delete ( $ params , $ optParams = [ ] ) { if ( is_string ( $ params ) ) { $ params = [ 'publicId' => $ params ] ; } return $ this -> sendRequest ( [ 'cloudId' , 'publicId' ] , [ 'restAction' => 'delete' , 'uri' => '/c/<cloudId>/o/<publicId>' , 'params' => $ params , 'getParams' => $ optParams , ] , function ( $ response ) { return $ response -> success ; } ) ; } | Deletes an image . |
24,062 | public function deleteByTag ( $ params , $ optParams = [ ] ) { if ( is_string ( $ params ) ) { $ params = [ 'tag' => $ params ] ; } return $ this -> sendRequest ( [ 'cloudId' , 'tag' ] , [ 'restAction' => 'delete' , 'uri' => '/c/<cloudId>/t/<tag>' , 'params' => $ params , 'getParams' => $ optParams , ] , function ( $ response ) { return isset ( $ response -> data ) ? new Job ( $ response -> data ) : $ response ; } ) ; } | Deletes images by tag . |
24,063 | public function exists ( $ params , $ optParams = [ ] ) { if ( is_string ( $ params ) ) { $ params = [ 'publicId' => $ params ] ; } return $ this -> sendRequest ( [ 'cloudId' , 'publicId' ] , [ 'restAction' => 'exists' , 'uri' => '/c/<cloudId>/o/<publicId>' , 'params' => $ params , 'getParams' => $ optParams , ] , function ( $ response ) { return $ response -> success ; } ) ; } | Returns whether an image exists . |
24,064 | public function buffer ( Context $ context ) : Promise { return $ context -> task ( function ( Context $ context ) { $ buffer = '' ; try { while ( null !== ( $ chunk = yield $ this -> read ( $ context , 0xFFFF ) ) ) { $ buffer .= $ chunk ; } } finally { $ this -> close ( ) ; } return $ buffer ; } ) ; } | Buffer remaining stream contents in memory and close the stream . |
24,065 | public function pipe ( Context $ context , WritableStream $ stream , bool $ close = false ) : Promise { return $ context -> task ( function ( Context $ context ) use ( $ stream , $ close ) { $ len = 0 ; try { while ( null != ( $ chunk = yield $ this -> read ( $ context , 0xFFFF ) ) ) { $ len += yield $ stream -> write ( $ context , $ chunk ) ; } } finally { $ this -> close ( ) ; if ( $ close ) { $ stream -> close ( ) ; } } return $ len ; } ) ; } | Copy remaining stream contents to the given stream . |
24,066 | public function discard ( Context $ context ) : Promise { return $ context -> task ( function ( Context $ context ) { $ len = 0 ; try { while ( null !== ( $ chunk = yield $ this -> read ( $ context , 0xFFFF ) ) ) { $ len += \ strlen ( $ chunk ) ; } } catch ( StreamClosedException $ e ) { } finally { $ this -> close ( ) ; } return $ len ; } ) ; } | Discard remaining stream contents and close the stream . |
24,067 | public function addDataFixtures ( array $ fixturesPaths ) : Descriptor { if ( ! empty ( $ fixturesPaths ) ) { foreach ( $ fixturesPaths as $ path ) { $ this -> dataFixtures -> add ( $ path ) ; } } return $ this ; } | Adds names of files with data fixtures from bundle |
24,068 | public function getShortName ( ) : string { if ( empty ( $ this -> shortName ) ) { $ name = strtolower ( $ this -> getName ( ) ) ; $ replaced = preg_replace ( '|bundle$|' , '' , $ name ) ; $ this -> shortName = trim ( $ replaced ) ; } return $ this -> shortName ; } | Returns short simple name of bundle |
24,069 | public function toArray ( bool $ withParentAndChild = true ) : array { $ array = [ 'name' => $ this -> getName ( ) , 'shortName' => $ this -> getShortName ( ) , 'configurationRootName' => $ this -> getConfigurationRootName ( ) , 'rootNamespace' => $ this -> getRootNamespace ( ) , 'path' => $ this -> getPath ( ) , 'dataFixtures' => $ this -> getDataFixtures ( ) -> toArray ( ) , ] ; if ( $ withParentAndChild ) { if ( null !== $ this -> getParentBundleDescriptor ( ) ) { $ array [ 'parentBundleDescriptor' ] = $ this -> getParentBundleDescriptor ( ) -> toArray ( false ) ; } if ( null !== $ this -> getChildBundleDescriptor ( ) ) { $ array [ 'childBundleDescriptor' ] = $ this -> getChildBundleDescriptor ( ) -> toArray ( false ) ; } } return $ array ; } | Returns an array representation of the descriptor |
24,070 | public static function fromArray ( array $ data ) : Descriptor { $ name = '' ; $ configurationRootName = '' ; $ rootNamespace = '' ; $ path = '' ; $ parentBundleDescriptor = null ; $ childBundleDescriptor = null ; if ( array_key_exists ( 'name' , $ data ) && ! empty ( $ data [ 'name' ] ) ) { $ name = $ data [ 'name' ] ; } if ( array_key_exists ( 'configurationRootName' , $ data ) && ! empty ( $ data [ 'configurationRootName' ] ) ) { $ configurationRootName = $ data [ 'configurationRootName' ] ; } if ( array_key_exists ( 'rootNamespace' , $ data ) && ! empty ( $ data [ 'rootNamespace' ] ) ) { $ rootNamespace = $ data [ 'rootNamespace' ] ; } if ( array_key_exists ( 'path' , $ data ) && ! empty ( $ data [ 'path' ] ) ) { $ path = $ data [ 'path' ] ; } if ( array_key_exists ( 'parentBundleDescriptor' , $ data ) && ! empty ( $ data [ 'parentBundleDescriptor' ] ) ) { $ parentData = $ data [ 'parentBundleDescriptor' ] ; $ parentBundleDescriptor = static :: fromArray ( $ parentData ) ; } if ( array_key_exists ( 'childBundleDescriptor' , $ data ) && ! empty ( $ data [ 'childBundleDescriptor' ] ) ) { $ childData = $ data [ 'childBundleDescriptor' ] ; $ childBundleDescriptor = static :: fromArray ( $ childData ) ; } return new static ( $ name , $ configurationRootName , $ rootNamespace , $ path , $ parentBundleDescriptor , $ childBundleDescriptor ) ; } | Creates and returns descriptor from given data |
24,071 | public static function fromBundle ( Bundle $ bundle ) : Descriptor { $ name = $ bundle -> getName ( ) ; $ rootNamespace = $ bundle -> getNamespace ( ) ; $ path = $ bundle -> getPath ( ) ; $ configurationRootName = '' ; return new static ( $ name , $ configurationRootName , $ rootNamespace , $ path ) ; } | Creates and returns descriptor of given bundle |
24,072 | public static function addJavascripts ( $ culture = null ) { $ path = sfConfig :: get ( 'sf_sfSelect2Widgets_select2_web_dir' ) ; $ available_cultures = sfConfig :: get ( 'sf_sfSelect2Widgets_available_cultures' ) ; $ javascripts = array ( $ path . '/select2.js' ) ; if ( $ culture != 'en' && in_array ( $ culture , $ available_cultures ) ) { $ javascripts [ ] = $ path . '/select2_locale_' . $ culture . '.js' ; } return $ javascripts ; } | Adds javascripts for Select2 Widgets |
24,073 | public function aggregate ( $ healths ) { $ statusCandidates = [ ] ; foreach ( $ healths as $ key => $ health ) { $ statusCandidates [ ] = $ health -> getStatus ( ) ; } $ status = $ this -> aggregateStatus ( $ statusCandidates ) ; $ details = $ this -> aggregateDetails ( $ healths ) ; $ builder = new HealthBuilder ( $ status , $ details ) ; return $ builder -> build ( ) ; } | Aggregate several given Health instances into one . |
24,074 | public function upload ( $ params , $ optParams = [ ] ) { $ resource = null ; if ( is_string ( $ params ) || is_resource ( $ params ) ) { $ params = [ 'file' => $ params ] ; } elseif ( is_array ( $ params ) && isset ( $ params [ 'tmp_name' ] ) ) { $ params = [ 'file' => $ params [ 'tmp_name' ] ] ; } if ( isset ( $ params [ 'file' ] ) && is_array ( $ params [ 'file' ] ) && isset ( $ params [ 'file' ] [ 'tmp_name' ] ) ) { $ params [ 'file' ] = $ params [ 'file' ] [ 'tmp_name' ] ; } if ( isset ( $ params [ 'file' ] ) && is_string ( $ params [ 'file' ] ) ) { $ resource = $ params [ 'file' ] = fopen ( $ params [ 'file' ] , 'r' ) ; } ArrayHelper :: stringify ( $ optParams , [ 'transformation' , ] ) ; return $ this -> sendRequest ( [ 'cloudId' , 'file' ] , [ 'restAction' => 'create' , 'uri' => '/c/<cloudId>' , 'params' => $ params , 'postParams' => array_merge ( $ params , $ optParams ) , ] , function ( $ response ) use ( $ resource ) { if ( is_resource ( $ resource ) ) { fclose ( $ resource ) ; } return isset ( $ response -> data ) ? new Image ( $ response -> data ) : $ response ; } ) ; } | Uploads an image from a local source . |
24,075 | public function concat ( $ string ) : self { Assert :: typeOf ( [ 'string' , __CLASS__ ] , $ string ) ; return new static ( $ this -> data . $ string , $ this -> encoding ) ; } | Concatenates given string to the end of this string |
24,076 | public static function copyValueOf ( $ charList ) : self { Assert :: typeOf ( [ 'string' , 'array' , __CLASS__ ] , $ charList ) ; $ string = '' ; if ( \ is_array ( $ charList ) ) { foreach ( $ charList as $ value ) { $ string .= static :: valueOf ( $ value ) ; } } else { $ string = ( string ) $ charList ; } return new static ( $ string ) ; } | Returns a string that represents the character sequence in the array specified |
24,077 | public function explode ( $ delimiter ) : array { Assert :: typeOf ( [ 'string' , __CLASS__ ] , $ delimiter ) ; $ response = [ ] ; $ results = explode ( ( string ) $ delimiter , $ this -> data ) ; if ( $ results === false ) { throw new RuntimeException ( 'An unknown error occurred while splitting string!' ) ; } foreach ( $ results as $ result ) { $ response [ ] = new static ( $ result , $ this -> encoding ) ; } return $ response ; } | Explodes this string by specified delimiter |
24,078 | public static function format ( $ format , ... $ args ) : self { Assert :: typeOf ( [ 'string' , __CLASS__ ] , $ format ) ; return new static ( sprintf ( ( string ) $ format , ... $ args ) ) ; } | Returns a formatted string using the given format and arguments |
24,079 | public function getChars ( int $ begin , int $ end , array & $ destination , int $ dstBegin ) : void { $ length = $ end - $ begin + 1 ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ destination [ $ dstBegin + $ i ] = $ this -> charAt ( $ begin + $ i ) ; } } | Copies characters from this string into the destination array |
24,080 | public function indexOf ( $ string , int $ offset = 0 ) : int { Assert :: typeOf ( [ 'string' , __CLASS__ ] , $ string ) ; $ pos = mb_strpos ( $ this -> data , ( string ) $ string , $ offset , $ this -> encoding ) ; return $ pos > - 1 ? $ pos : - 1 ; } | Returns the index within this string of the first occurrence of the specified string |
24,081 | public function lastIndexOf ( $ string , int $ offset = 0 ) : int { Assert :: typeOf ( [ 'string' , __CLASS__ ] , $ string ) ; $ pos = mb_strrpos ( $ this -> data , ( string ) $ string , $ offset , $ this -> encoding ) ; return $ pos > - 1 ? $ pos : - 1 ; } | Returns the index within this string of the last occurrence of the specified string |
24,082 | public function matches ( $ pattern ) : bool { Assert :: typeOf ( [ 'string' , __CLASS__ ] , $ pattern ) ; return preg_match ( ( string ) $ pattern , $ this -> data ) === 1 ; } | Checks if this string matches the given regex pattern |
24,083 | public function regionMatches ( int $ offset , $ string , int $ strOffset , int $ len , bool $ ignoreCase = false ) : bool { Assert :: typeOf ( [ 'string' , __CLASS__ ] , $ string ) ; $ strLen = \ is_string ( $ string ) ? mb_strlen ( $ string , $ this -> encoding ) : $ string -> length ( ) ; if ( $ offset < 0 || $ strOffset < 0 || ( $ strOffset + $ len ) > $ strLen || ( $ offset + $ len ) > $ this -> length ( ) ) { return false ; } $ stringA = mb_substr ( $ this -> data , $ offset , $ len , $ this -> encoding ) ; $ stringB = mb_substr ( ( string ) $ string , $ strOffset , $ len , $ this -> encoding ) ; if ( $ ignoreCase ) { $ result = strcmp ( mb_strtolower ( $ stringA , $ this -> encoding ) , mb_strtolower ( $ stringB , $ this -> encoding ) ) ; } else { $ result = strcmp ( $ stringA , $ stringB ) ; } return $ result === 0 ; } | Checks if two string regions are equal |
24,084 | public function replaceFirst ( $ pattern , $ replacement ) : self { Assert :: typeOf ( [ 'string' , __CLASS__ ] , $ pattern , $ replacement ) ; $ result = preg_replace ( $ pattern , $ replacement , $ this -> data , 1 ) ; return new static ( $ result ? : $ this -> data , $ this -> encoding ) ; } | Replaces the first substring of this string that matches the given regex pattern with the specified replacement |
24,085 | public function split ( $ pattern , int $ limit = - 1 ) : array { Assert :: typeOf ( [ 'string' , __CLASS__ ] , $ pattern ) ; $ response = [ ] ; $ results = preg_split ( ( string ) $ pattern , $ this -> data , $ limit ) ; if ( $ results === false ) { throw new RuntimeException ( 'An unknown error occurred while splitting string!' ) ; } foreach ( $ results as $ result ) { $ response [ ] = new static ( $ result , $ this -> encoding ) ; } return $ response ; } | Splits this string around matches of the given regex pattern |
24,086 | public function substr ( int $ start , int $ length = null ) : self { if ( $ start < 0 ) { throw new InvalidArgumentException ( 'Negative index is not allowed!' ) ; } return new static ( mb_substr ( $ this -> data , $ start , $ length , $ this -> encoding ) , $ this -> encoding ) ; } | Returns a new string object that is a substring of this string |
24,087 | public static function valueOf ( $ value ) : self { $ strVal = null ; switch ( gettype ( $ value ) ) { case 'object' : if ( $ value instanceof StdObject || ( \ is_object ( $ value ) && method_exists ( $ value , '__toString' ) ) ) { $ strVal = ( string ) $ value ; } break ; case 'boolean' : $ strVal = $ value ? 'true' : 'false' ; break ; case 'double' : case 'integer' : case 'string' : $ strVal = ( string ) $ value ; break ; } if ( $ strVal === null ) { throw new InvalidArgumentException ( 'Unsupported value type!' ) ; } return new static ( $ strVal ) ; } | Returns the string representation of the given value |
24,088 | public function read ( AbstractStream $ stream ) { return $ stream -> getBuffer ( ) -> read ( $ this -> getSize ( ) , $ this -> getEndian ( ) ) ; } | Read string from stream as it is . |
24,089 | public function handleBackActions ( ) : void { if ( ! $ this -> request -> getSession ( ) -> check ( 'back_action' ) ) { $ this -> request -> getSession ( ) -> write ( 'back_action' , [ ] ) ; } if ( ! empty ( $ this -> request -> getQuery ( 'back_action' ) ) ) { $ requestedBackAction = $ this -> request -> getQuery ( 'back_action' ) ; $ requestedAction = $ this -> getRequestedAction ( ) ; if ( ! $ this -> request -> getSession ( ) -> check ( 'back_action.' . $ requestedBackAction ) || ( $ this -> request -> getSession ( ) -> check ( 'back_action.' . $ requestedBackAction ) && $ this -> request -> getSession ( ) -> read ( 'back_action.' . $ requestedBackAction ) != $ requestedAction ) && ! $ this -> request -> getSession ( ) -> check ( 'back_action.' . $ requestedAction ) ) { $ this -> request -> getSession ( ) -> write ( 'back_action.' . $ requestedAction , $ requestedBackAction ) ; } } } | persists requested back actions with their context in session |
24,090 | public function augmentUrlByBackParam ( array $ url ) : array { $ backAction = $ this -> request -> getRequestTarget ( ) ; if ( $ this -> request -> is ( 'ajax' ) ) { $ backAction = $ this -> request -> referer ( true ) ; } $ backAction = preg_replace ( '/back_action=.*?(&|$)/' , '' , $ backAction ) ; $ url [ '?' ] [ 'back_action' ] = preg_replace ( '/\\?$/' , '' , $ backAction ) ; return $ url ; } | Adds a back action get param to an url array |
24,091 | private function getDifference ( $ value ) : ? int { $ now = ( new \ DateTime ( ) ) -> setTime ( 0 , 0 ) ; $ date = Date :: getDateTime ( $ value ) ; if ( $ date instanceof \ DateTime ) { return Date :: getDateDifference ( $ now , $ date , Date :: DATE_DIFFERENCE_UNIT_DAYS ) ; } return null ; } | Returns difference between validated date and today |
24,092 | private function isValid ( Constraint $ constraint , int $ difference ) : bool { if ( $ constraint instanceof EarlierThanToday && $ difference < 0 ) { return true ; } if ( $ constraint instanceof EarlierThanOrEqualToday && $ difference <= 0 ) { return true ; } if ( $ constraint instanceof LaterThanToday && $ difference > 0 ) { return true ; } if ( $ constraint instanceof LaterThanOrEqualToday && $ difference >= 0 ) { return true ; } return false ; } | Returns information if processing date is valid . Based on given constraint and difference between the date and today . |
24,093 | public static function exists ( $ array , $ key ) { $ key = static :: normalizeKey ( $ key ) ; if ( $ key === null || $ key === '' || static :: isEmpty ( $ array ) ) { return false ; } $ keys = explode ( '.' , $ key ) ; $ currentElement = $ array ; foreach ( $ keys as $ currentKey ) { if ( ! is_array ( $ currentElement ) || ! array_key_exists ( $ currentKey , $ currentElement ) ) { return false ; } $ currentElement = $ currentElement [ ( string ) $ currentKey ] ; } return true ; } | Check if given key exists in array with dot notation support . |
24,094 | public static function get ( $ array , $ key , $ default = null ) { $ key = static :: normalizeKey ( $ key ) ; if ( $ key === null || $ key === '' ) { return $ array ; } $ keys = explode ( '.' , $ key ) ; $ currentElement = $ array ; foreach ( $ keys as $ currentKey ) { if ( ! is_array ( $ currentElement ) || ! array_key_exists ( $ currentKey , $ currentElement ) ) { return $ default ; } $ currentElement = $ currentElement [ ( string ) $ currentKey ] ; } return $ currentElement ; } | Return the value stored under given key in the array with dot notation support . |
24,095 | public static function set ( & $ array , $ key , $ value ) { $ key = static :: normalizeKey ( $ key ) ; if ( $ key === null || $ key === '' ) { return ( $ array = $ value ) ; } $ keys = explode ( '.' , $ key ) ; $ last = array_pop ( $ keys ) ; $ currentElement = & $ array ; foreach ( $ keys as $ currentKey ) { if ( ! array_key_exists ( $ currentKey , $ currentElement ) || ! is_array ( $ currentElement [ $ currentKey ] ) ) { $ currentElement [ $ currentKey ] = [ ] ; } $ currentElement = & $ currentElement [ $ currentKey ] ; } $ currentElement [ $ last ] = $ value ; return $ array ; } | Set the value for given key in the array with dot notation support . |
24,096 | public static function expand ( $ array ) { $ multiArray = [ ] ; foreach ( $ array as $ key => & $ value ) { $ keys = explode ( '.' , $ key ) ; $ lastKey = array_pop ( $ keys ) ; $ currentPointer = & $ multiArray ; foreach ( $ keys as $ currentKey ) { if ( ! isset ( $ currentPointer [ $ currentKey ] ) ) { $ currentPointer [ $ currentKey ] = [ ] ; } $ currentPointer = & $ currentPointer [ $ currentKey ] ; } $ currentPointer [ $ lastKey ] = $ value ; } return $ multiArray ; } | Expand flattened array into a multi - dimensional one . |
24,097 | public static function merge ( $ arrays ) { $ merged = [ ] ; foreach ( $ arrays as $ array ) { $ merged = array_merge ( $ merged , static :: flatten ( $ array ) ) ; } return static :: expand ( $ merged ) ; } | Merge several arrays preserving dot notation . |
24,098 | protected static function flattenRecursive ( & $ recursion , $ prefix ) { $ values = [ ] ; foreach ( $ recursion as $ key => & $ value ) { if ( is_array ( $ value ) && ! empty ( $ value ) ) { $ values = array_merge ( $ values , static :: flattenRecursive ( $ value , $ prefix . $ key . '.' ) ) ; } else { $ values [ $ prefix . $ key ] = $ value ; } } return $ values ; } | Flatten a single recursion of array . |
24,099 | public function registerFindables ( ConfigInterface $ config ) { $ findables = ( array ) $ config -> getKey ( $ this -> getFindablesConfigKey ( ) ) ; foreach ( $ findables as $ findableKey => $ findableObject ) { $ this -> findables -> set ( $ findableKey , $ findableObject ) ; } } | Register the Findables defined in the given configuration . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.