idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
4,000 | public function hashToFieldValue ( $ fieldValue , array $ context = array ( ) ) { if ( is_array ( $ fieldValue ) && array_key_exists ( 'destinationContentId' , $ fieldValue ) ) { $ id = $ fieldValue [ 'destinationContentId' ] ; } else { $ id = $ fieldValue ; } if ( $ id === null ) { return new Value ( ) ; } $ id = $ th... | Creates a value object to use as the field value when setting an ez relation field type . |
4,001 | public function hashToFieldValue ( $ fieldValue , array $ context = array ( ) ) { $ fileName = '' ; $ mimeType = '' ; $ hasController = false ; $ autoPlay = false ; $ loop = false ; $ height = 0 ; $ width = 0 ; if ( $ fieldValue === null ) { return new MediaValue ( ) ; } else if ( is_string ( $ fieldValue ) ) { $ fileP... | Creates a value object to use as the field value when setting a media field type . |
4,002 | public static function create ( $ name , $ description = "" , $ permission_id = null ) { $ perm = new self ( ) ; $ perm -> name = $ name ; $ perm -> description = $ description ; $ perm -> permission_id = $ permission_id ; return $ perm ; } | Configure and return a new Permission instance ready to be saved to the backend data store |
4,003 | public function track ( array $ queries ) { if ( count ( $ queries ) == 0 ) return null ; $ data = [ 'query' => $ this -> prepareQuery ( $ queries ) , 'arguments' => $ this -> prepareArguments ( $ queries ) , ] ; return $ this -> getModel ( ) -> newQuery ( ) -> firstOrCreate ( Arr :: only ( $ data , [ 'query' ] ) , $ d... | Track the query . |
4,004 | public function hasPermission ( $ permission ) { if ( $ permission instanceof Permission ) { $ permission = $ permission -> name ; } return $ this -> getRoleSet ( ) -> has_permission ( $ permission ) ; } | Check if a user has access to the permission requested |
4,005 | public function search ( $ ipAddress ) { try { if ( $ location = $ this -> geoIp -> location ( $ ipAddress ) ) { return $ this -> transform ( $ location ) ; } } catch ( \ Exception $ e ) { } return null ; } | Get the geoip data . |
4,006 | private function transform ( $ location ) { return [ 'iso_code' => $ location -> iso_code , 'country' => $ location -> country , 'city' => $ location -> city , 'state' => $ location -> state , 'state_code' => $ location -> state_code , 'postal_code' => $ location -> postal_code , 'latitude' => $ location -> latitude , ... | Render the data . |
4,007 | private function registerDetectors ( ) { $ this -> singleton ( Contracts \ Detectors \ CrawlerDetector :: class , function ( AppContract $ app ) { $ request = $ app [ 'request' ] ; return new Detectors \ CrawlerDetector ( new \ Jaybizzle \ CrawlerDetect \ CrawlerDetect ( $ request -> headers -> all ( ) , $ request -> s... | Register the detectors . |
4,008 | private function registerParsers ( ) { $ this -> singleton ( Contracts \ Parsers \ RefererParser :: class , function ( ) { return new Parsers \ RefererParser ( new \ Snowplow \ RefererParser \ Parser ) ; } ) ; $ this -> singleton ( Contracts \ Parsers \ UserAgentParser :: class , function ( AppContract $ app ) { return... | Register the parsers . |
4,009 | public function addRole ( Role $ role ) { if ( ! in_array ( $ role , $ this -> roles ) ) { $ this -> roles [ ] = $ role ; return true ; } return false ; } | Add a new role to the role set |
4,010 | public function getPermissions ( ) { $ permissions = [ ] ; foreach ( $ this -> roles as $ role ) { $ permissions = array_merge ( $ permissions , $ role -> getPermissions ( ) ) ; } return array_unique ( $ permissions ) ; } | Fetch a complete set of unique permissions assigned to the users roles |
4,011 | public static function make ( $ errorCode , $ errorMessage ) { $ exception = Arr :: get ( self :: $ supported , $ errorCode , Errors \ Error :: class ) ; return new $ exception ( $ errorMessage , $ errorCode ) ; } | Make exception . |
4,012 | public function track ( $ cookie ) { if ( ! $ cookie ) { $ this -> cookie ( ) -> queue ( $ this -> cookie ( ) -> make ( $ this -> getConfig ( 'cookie.name' ) , $ cookie = ( string ) Uuid :: uuid4 ( ) ) ) ; } return $ this -> getModel ( ) -> newQuery ( ) -> firstOrCreate ( [ 'uuid' => $ cookie ] ) -> getKey ( ) ; } | Track the cookie . |
4,013 | public function track ( $ ipAddress ) { if ( $ data = $ this -> getGeoIpDetector ( ) -> search ( $ ipAddress ) ) { return $ this -> getModel ( ) -> newQuery ( ) -> firstOrCreate ( Arr :: only ( $ data , [ 'latitude' , 'longitude' ] ) , $ data ) -> getKey ( ) ; } return null ; } | Track the ip address . |
4,014 | public function getOperatingSystemVersion ( ) { $ os = $ this -> getOperatingSystem ( ) ; return $ this -> prepareVersion ( [ $ os -> major , $ os -> minor , $ os -> patch ] ) ; } | Get the OS version . |
4,015 | public function getUserAgentVersion ( ) { $ ua = $ this -> getUserAgent ( ) ; return $ this -> prepareVersion ( [ $ ua -> major , $ ua -> minor , $ ua -> patch ] ) ; } | Get the user agent version . |
4,016 | private function getCurrentDeviceProperties ( ) { if ( $ properties = $ this -> getDeviceDetector ( ) -> detect ( ) ) { $ parser = $ this -> getUserAgentParser ( ) ; $ properties [ 'platform' ] = $ parser -> getOperatingSystemFamily ( ) ; $ properties [ 'platform_version' ] = $ parser -> getOperatingSystemVersion ( ) ;... | Get the current device properties . |
4,017 | public function checkData ( array $ currentData , array $ newData ) { return ( $ currentData && $ newData && $ currentData !== $ newData ) ? $ this -> updateData ( $ newData ) : $ newData ; } | Check the visitor data . |
4,018 | private function getVisitorData ( $ column = null ) { $ data = $ this -> session ( ) -> get ( $ this -> getSessionKey ( ) ) ; return is_null ( $ column ) ? $ data : Arr :: get ( $ data , $ column , null ) ; } | Get the visitor data . |
4,019 | private function checkIfUserChanged ( array $ data ) { $ model = $ this -> getModel ( ) -> newQuery ( ) -> find ( $ this -> getVisitorData ( 'id' ) ) ; if ( ! is_null ( $ model ) && ! is_null ( $ model -> user_id ) && ! is_null ( $ data [ 'user_id' ] ) && $ data [ 'user_id' ] !== $ model -> user_id ) { $ newVisitor = $... | Check if user changed . |
4,020 | private function regenerateSystemVisitor ( $ data = null ) { $ data = $ data ? : $ this -> getVisitorData ( ) ; if ( $ data ) { $ this -> resetVisitorUuid ( $ data ) ; $ this -> createVisitorIfIsUnknown ( ) ; } return $ this -> visitorInfo ; } | Regenerate visitor data for the system . |
4,021 | private function resetVisitorUuid ( $ data = null ) { $ this -> visitorInfo [ 'uuid' ] = null ; $ data = $ data ? : $ this -> visitorInfo ; unset ( $ data [ 'uuid' ] ) ; $ this -> putSessionData ( $ data ) ; $ this -> checkVisitorUuid ( ) ; return $ data ; } | Reset the visitor uuid . |
4,022 | private function checkVisitorUuid ( ) { if ( ! isset ( $ this -> visitorInfo [ 'uuid' ] ) || ! $ this -> visitorInfo [ 'uuid' ] ) $ this -> visitorInfo [ 'uuid' ] = $ this -> getVisitorIdFromSystem ( ) ; } | Check the visitor uuid . |
4,023 | private function createVisitorIfIsUnknown ( ) { $ model = $ this -> getModel ( ) ; if ( $ this -> isVisitorKnown ( ) ) { $ visitor = $ model -> newQuery ( ) -> find ( $ id = $ this -> getVisitorData ( $ model -> getKeyName ( ) ) ) ; $ visitor -> updated_at = Carbon :: now ( ) ; $ visitor -> save ( ) ; $ this -> setVisi... | Create a new visitor if is unknown . |
4,024 | private function isVisitorKnown ( ) { if ( ! $ this -> session ( ) -> has ( $ this -> getSessionKey ( ) ) ) return false ; if ( $ this -> getVisitorData ( 'uuid' ) != $ this -> getVisitorIdFromSystem ( ) ) return false ; if ( ! $ this -> findByUuid ( $ this -> getVisitorData ( 'uuid' ) ) ) return false ; return true ; ... | Check if the visitor is known . |
4,025 | private function generateVisitor ( array $ visitorInfo ) { $ this -> visitorInfo = $ visitorInfo ; if ( ! $ this -> checkVisitorDataIsReliable ( ) ) $ this -> regenerateSystemVisitor ( ) ; $ this -> checkVisitorUuid ( ) ; } | Generate visitor data . |
4,026 | private function checkVisitorDataIsReliable ( ) { $ data = $ this -> getVisitorData ( ) ; foreach ( [ 'user_id' , 'client_ip' , 'user_agent' ] as $ key ) { if ( $ this -> checkDataIsUnreliable ( $ data , $ key ) ) return false ; } return true ; } | Check if the visitor data is reliable . |
4,027 | private function checkDataIsUnreliable ( $ data , $ key ) { return isset ( $ data [ $ key ] ) && ( $ data [ $ key ] !== $ this -> visitorInfo [ $ key ] ) ; } | Check the data is unreliable . |
4,028 | private function ensureVisitorDataIsComplete ( ) { $ visitorData = $ this -> getVisitorData ( ) ; $ completed = true ; foreach ( $ this -> visitorInfo as $ key => $ value ) { if ( $ visitorData [ $ key ] !== $ value ) { if ( ! isset ( $ model ) ) $ model = $ this -> getModel ( ) -> find ( $ this -> getVisitorId ( ) ) ;... | Ensure that the visitor data is complete . |
4,029 | public function track ( $ refererUrl , $ pageUrl ) { $ firstParsed = $ this -> getRefererParser ( ) -> parseUrl ( $ refererUrl ) ; if ( $ firstParsed ) { $ attributes = [ 'url' => $ firstParsed [ 'url' ] , 'host' => $ firstParsed [ 'host' ] , 'domain_id' => $ this -> trackDomain ( $ firstParsed [ 'domain' ] ) , 'medium... | Track the referer and return the id . |
4,030 | private function trackDomain ( $ name ) { return $ this -> makeModel ( BindingManager :: MODEL_DOMAIN ) -> newQuery ( ) -> firstOrCreate ( compact ( 'name' ) ) -> getKey ( ) ; } | Track the domain and get the id . |
4,031 | private function trackRefererSearchTerms ( $ referer , $ searchTerms ) { $ terms = [ ] ; foreach ( explode ( ' ' , $ searchTerms ) as $ term ) { $ terms [ ] = $ this -> makeModel ( BindingManager :: MODEL_REFERER_SEARCH_TERM ) -> fill ( [ 'search_term' => $ term , ] ) ; } if ( count ( $ terms ) > 0 ) $ referer -> searc... | Store the referer s search terms . |
4,032 | protected function traverse ( $ key , $ returnValue = true ) { $ value = $ this -> values ; foreach ( explode ( '.' , $ key ) as $ part ) { if ( ! array_key_exists ( $ part , $ value ) ) { return false ; } $ value = $ value [ $ part ] ; } return $ returnValue ? $ value : true ; } | Traverses the key using dot notation . Based on the second parameter it will return the value or if it was set . |
4,033 | protected function setTraverse ( $ key , $ value ) { $ parts = explode ( '.' , $ key ) ; $ ref = & $ this -> values ; foreach ( $ parts as $ i => $ part ) { $ ref = & $ ref [ $ part ] ; } $ ref = $ value ; return $ this ; } | Uses dot - notation to set a value . |
4,034 | public function cut ( $ start , $ length = null ) { return $ this -> addRule ( new FilterRule \ Cut ( $ start , $ length ) ) ; } | Results rule that returns the cut value |
4,035 | public function decodeJSON ( $ assoc = true , $ depth = 512 , $ options = 0 ) { return $ this -> addRule ( new FilterRule \ DecodeJSON ( $ assoc , $ depth , $ options ) ) ; } | Returns rule that decodes JSON code of a given value |
4,036 | public function encode ( $ toEncodingFormat = null , $ fromEncodingFormat = null ) { return $ this -> addRule ( new FilterRule \ Encode ( $ toEncodingFormat , $ fromEncodingFormat ) ) ; } | Returns rule that returns an value in a specific encoding format |
4,037 | public function numberFormat ( $ decimals , $ decimalPoint , $ thousandSeparator ) { return $ this -> addRule ( new FilterRule \ NumberFormat ( $ decimals , $ decimalPoint , $ thousandSeparator ) ) ; } | Returns rule that formats numbers |
4,038 | public function filter ( $ value ) { if ( $ this -> encodingFormat !== null ) { return mb_strtoupper ( $ value , $ this -> encodingFormat ) ; } return mb_strtoupper ( $ value ) ; } | Uppercase the given value |
4,039 | public function addFilterRule ( FilterRule $ rule , $ key = null ) { $ this -> getChain ( $ key ) -> addRule ( $ rule , $ this -> encodingFormat ) ; } | Set a filter rule on a chain |
4,040 | public function filter ( array $ data ) { $ data = $ this -> filterArrayWithGlobalChain ( $ data ) ; $ this -> data = new Container ( $ data ) ; $ this -> filterChains ( ) ; return $ this -> data -> getArrayCopy ( ) ; } | Filter the provided data |
4,041 | protected function filterArrayWithGlobalChain ( array $ data ) { if ( $ this -> globalChain === null ) { return $ data ; } foreach ( $ data as $ key => $ value ) { $ data = $ this -> filterValueWithGlobalChain ( $ value , $ key , $ data ) ; } return array_filter ( $ data ) ; } | Filter all set fields with a global chain recursively |
4,042 | protected function filterValueWithGlobalChain ( $ value , $ key , $ data ) { if ( is_array ( $ value ) ) { $ data [ $ key ] = $ this -> filterArrayWithGlobalChain ( $ value ) ; return $ data ; } $ filterResult = $ this -> globalChain -> filter ( true , $ value , $ data ) ; if ( $ filterResult -> isNotEmpty ( ) ) { $ da... | Filters a value with the global chain |
4,043 | protected function getFilterResult ( $ key , Chain $ chain ) { if ( $ this -> data -> has ( $ key ) ) { return $ chain -> filter ( true , $ this -> data -> get ( $ key ) , $ this -> data -> getArrayCopy ( ) ) ; } return $ chain -> filter ( false , null , $ this -> data -> getArrayCopy ( ) ) ; } | Get the filter result from a chain |
4,044 | protected function filterChains ( ) { foreach ( $ this -> chains as $ key => $ chain ) { $ filterResult = $ this -> getFilterResult ( $ key , $ chain ) ; if ( $ filterResult -> isNotEmpty ( ) ) { $ this -> data -> set ( $ key , $ filterResult -> getFilteredValue ( ) ) ; } else { $ this -> data -> remove ( $ key ) ; } }... | Filter all chains set |
4,045 | protected function getChain ( $ key ) { if ( $ key === null ) { return $ this -> getGlobalChain ( ) ; } if ( isset ( $ this -> chains [ $ key ] ) ) { return $ this -> chains [ $ key ] ; } return $ this -> chains [ $ key ] = $ this -> buildChain ( ) ; } | Get a filter rule chain for a key |
4,046 | protected function getGlobalChain ( ) { if ( $ this -> globalChain === null ) { $ this -> globalChain = $ this -> buildChain ( ) ; } return $ this -> globalChain ; } | Get the global chain for all values |
4,047 | public function filter ( $ isSet , $ value = null , $ filterData = null ) { foreach ( $ this -> rules as $ rule ) { $ rule -> setFilterData ( $ filterData ) ; if ( $ isSet || $ rule -> allowedNotSet ( ) ) { $ value = $ rule -> filter ( $ value ) ; $ isSet = $ rule -> isNotEmpty ( ) ; } } return new FilterResult ( $ isS... | Execute all filters in the chain |
4,048 | function describe ( ) { return get_class ( $ this ) . ": \"" . $ this -> getMessage ( ) . "\" (http_status: " . $ this -> getHttpStatus ( ) . ", reason_code: " . $ this -> getReasonCode ( ) . ", source: " . $ this -> getSource ( ) . ")" ; } | Returns a description of the error . |
4,049 | protected function push ( ) { if ( ! Config :: get ( 'vdeploy::config.push' ) ) { return true ; } passthru ( 'git push' , $ code ) ; if ( $ code ) { $ this -> error ( "FAILED: git push" ) ; return false ; } passthru ( 'git push --tags' , $ code ) ; if ( $ code ) { $ this -> error ( "Failed: git push --tags" ) ; return ... | Runs the push if requested |
4,050 | protected function production ( ) { if ( ! Config :: get ( 'vdeploy::config.production.enabled' ) ) { return true ; } $ remote = $ this -> argument ( 'remote' ) ; if ( $ remote != Config :: get ( 'vdeploy::config.production.name' ) ) { return true ; } $ rawTag = trim ( `git describe --tags --match 'v[0-9]*'`); $... | Runs the production code if requested |
4,051 | protected function incrementTag ( $ current , $ major , $ minor , $ patch , $ preRelease , $ preIncrement ) { $ this -> line ( '' ) ; $ this -> info ( "The current release version is: {$current}." ) ; $ tag [ 'major' ] = 'v' . ( $ major + 1 ) . '.0.0' ; $ tag [ 'minor' ] = "v{$major}." . ( $ minor + 1 ) . '.0' ; $ tag ... | Increments the tag based on argument or user input |
4,052 | protected function runCommands ( ) { $ remote = $ this -> argument ( 'remote' ) ; $ directory = Config :: get ( 'remote.connections.' . $ remote . '.root' ) ; $ commands = array_merge ( [ 'cd ' . $ directory ] , Config :: get ( 'vdeploy::config.commands' ) ) ; $ commands = array_filter ( $ commands ) ; if ( ! $ this ->... | Runs the SSH commands on the remote |
4,053 | protected function parseTags ( & $ command ) { if ( is_array ( $ command ) ) { foreach ( $ command as & $ cmd ) { if ( ! $ this -> parseTags ( $ cmd ) ) { return false ; } } return true ; } while ( preg_match ( self :: REGEX_TAG , $ command , $ matches ) ) { try { $ value = $ this -> userOption ( $ matches [ 2 ] ) ; } ... | Parses the user tags in the commands array |
4,054 | public function filter ( $ value ) { if ( empty ( $ value ) && isset ( $ this -> filterData [ $ this -> fieldToSlugFrom ] ) ) { $ value = $ this -> filterData [ $ this -> fieldToSlugFrom ] ; } if ( is_null ( $ value ) ) { return $ this -> setEmpty ( ) ; } $ value = transliterator_transliterate ( $ this -> transliterato... | Slug the value of either the actual field of the given one . |
4,055 | public function filter ( $ value ) { if ( $ this -> encodingFormat !== null ) { return mb_substr ( $ value , $ this -> start , $ this -> length , $ this -> encodingFormat ) ; } return mb_substr ( $ value , $ this -> start , $ this -> length ) ; } | Cuts the given value |
4,056 | public function filter ( $ values ) { if ( is_array ( $ values ) ) { foreach ( $ values as $ key => $ value ) { $ values [ $ key ] = $ this -> filterValue ( $ value ) ; } } return $ values ; } | When provided with an array the callback filter will be executed for every value |
4,057 | protected function filterValue ( $ value ) { $ filter = new Filter ( ) ; call_user_func ( $ this -> callable , $ filter ) ; return $ filter -> filter ( $ value ) ; } | Filter a given value with a new filter instance in a callable |
4,058 | public function getUrl ( $ operationConfig , $ operationMetadata , & $ inputMap ) { $ queryParams = array ( ) ; $ action = $ operationConfig -> getAction ( ) ; $ resourcePath = $ operationConfig -> getResourcePath ( ) ; $ queryList = $ operationConfig -> getQueryParams ( ) ; $ resolvedHostUrl = $ operationMetadata -> g... | This method generated the URL |
4,059 | public function getRequest ( $ operationConfig , $ operationMetadata , & $ inputMap ) { $ action = $ operationConfig -> getAction ( ) ; $ resourcePath = $ operationConfig -> getResourcePath ( ) ; $ headerList = $ operationConfig -> getHeaderParams ( ) ; $ queryList = $ operationConfig -> getQueryParams ( ) ; $ headerMa... | This is the function that returns a Request object |
4,060 | public function execute ( $ operationConfig , $ operationMetadata , $ inputMap ) { $ request = $ this -> getRequest ( $ operationConfig , $ operationMetadata , $ inputMap ) ; try { $ response = $ this -> client -> send ( $ request , array_merge ( ApiConfig :: getProxy ( ) , ApiConfig :: getTimeout ( ) ) ) ; $ statusCod... | This function executes the request |
4,061 | public function loadDomDocument ( \ DOMDocument $ domDocument ) { $ this -> _dom = $ domDocument ; foreach ( $ this -> _getNodesForCssSelector ( '[style]' ) as $ node ) { $ node -> setAttribute ( 'inlinestyle-original-style' , $ node -> getAttribute ( 'style' ) ) ; } } | Load the HTML as a DOMDocument directly |
4,062 | public function applyStylesheet ( $ stylesheet ) { $ stylesheet = ( array ) $ stylesheet ; foreach ( $ stylesheet as $ ss ) { $ parsed = $ this -> parseStylesheet ( $ ss ) ; $ parsed = $ this -> sortSelectorsOnSpecificity ( $ parsed ) ; foreach ( $ parsed as $ arr ) { list ( $ selector , $ style ) = $ arr ; $ this -> a... | Applies one or more stylesheets to the current document |
4,063 | public function applyRule ( $ selector , $ style ) { if ( $ selector ) { $ nodes = $ this -> _getNodesForCssSelector ( $ selector ) ; $ style = $ this -> _styleToArray ( $ style ) ; foreach ( $ nodes as $ node ) { $ current = $ node -> hasAttribute ( "style" ) ? $ this -> _styleToArray ( $ node -> getAttribute ( "style... | Applies a style rule on the document |
4,064 | public function getHTML ( ) { $ clone = clone $ this ; foreach ( $ clone -> _getNodesForCssSelector ( '[inlinestyle-original-style]' ) as $ node ) { $ current = $ node -> hasAttribute ( "style" ) ? $ this -> _styleToArray ( $ node -> getAttribute ( "style" ) ) : array ( ) ; $ original = $ node -> hasAttribute ( "inline... | Returns the DOMDocument as html |
4,065 | public function extractStylesheets ( $ node = null , $ base = '' , $ devices = array ( 'all' , 'screen' , 'handheld' ) , $ remove = true ) { if ( null === $ node ) { $ node = $ this -> _dom ; } $ stylesheets = array ( ) ; if ( $ node -> hasChildNodes ( ) ) { $ removeQueue = array ( ) ; foreach ( $ node -> childNodes as... | Recursively extracts the stylesheet nodes from the DOMNode |
4,066 | public function extractStylesheetsWithXpath ( $ xpathQuery ) { $ stylesheets = array ( ) ; $ nodes = $ this -> _getDomXpath ( ) -> query ( $ xpathQuery ) ; foreach ( $ nodes as $ node ) { $ stylesheets [ ] = $ node -> nodeValue ; $ node -> parentNode -> removeChild ( $ node ) ; } return $ stylesheets ; } | Extracts the stylesheet nodes nodes specified by the xpath |
4,067 | public function parseStylesheet ( $ stylesheet ) { $ parsed = array ( ) ; $ stylesheet = $ this -> _stripStylesheet ( $ stylesheet ) ; $ stylesheet = trim ( trim ( $ stylesheet ) , "}" ) ; foreach ( explode ( "}" , $ stylesheet ) as $ rule ) { if ( ! trim ( $ rule ) ) continue ; list ( $ selector , $ style ) = explode ... | Parses a stylesheet to selectors and properties |
4,068 | private function _mergeStyles ( array $ styleA , array $ styleB ) { foreach ( $ styleB as $ prop => $ val ) { if ( ! isset ( $ styleA [ $ prop ] ) || substr ( str_replace ( " " , "" , strtolower ( $ styleA [ $ prop ] ) ) , - 10 ) !== "!important" ) { $ styleA [ $ prop ] = $ val ; } } return $ styleA ; } | Merges two sets of style properties taking !important into account |
4,069 | public function filter ( $ value ) { if ( empty ( $ value ) ) { return $ value ; } return number_format ( floatval ( $ value ) , $ this -> decimals , $ this -> decimalPoint , $ this -> thousandSeparator ) ; } | Format the numbers |
4,070 | public function containsKey ( $ key ) { if ( strpos ( $ key , "." ) !== false ) { $ keys = explode ( '.' , $ key ) ; $ keysCount = count ( $ keys ) ; $ tmpArray = $ this -> properties ; foreach ( $ keys as $ index => $ subKey ) { if ( empty ( $ tmpArray ) || empty ( $ subKey ) ) { return false ; } else if ( $ index + 1... | This check is the map contains a key |
4,071 | public function setAll ( $ map ) { if ( $ map instanceof SmartMap ) { $ this -> properties = array_merge ( $ this -> properties , $ map -> getBaseMapAsArray ( ) ) ; } else { if ( $ this -> isAssoc ( $ map ) ) { foreach ( $ map as $ key => $ value ) { $ this -> set ( $ key , $ value ) ; } } else if ( is_array ( $ map ) ... | Updates the object s properties with the values in the specified map . |
4,072 | public function filter ( $ value ) { if ( ! is_string ( $ value ) ) { return $ value ; } return json_decode ( $ value , $ this -> assoc , $ this -> depth , $ this -> options ) ; } | Decodes the value JSON |
4,073 | public function init ( ) { parent :: init ( ) ; if ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) === 'WIN' ) { $ this -> windows = true ; } if ( $ this -> resource_directory ) { if ( ! file_exists ( $ this -> resource_directory ) ) { throw new Exception ( 'Invalid resource directory' , 1 ) ; } } } | Initializes the Jasper component . |
4,074 | public function process ( $ input_file , $ parameters = [ ] , $ format = [ 'pdf' ] , $ output_file = false ) { if ( is_null ( $ input_file ) || empty ( $ input_file ) ) { throw new Exception ( 'No input file' , 1 ) ; } if ( is_array ( $ format ) ) { foreach ( $ format as $ key ) { if ( ! in_array ( $ key , $ this -> fo... | Process report . Accepts files in the format . jrxml or . jasper . |
4,075 | public function execute ( ) { $ this -> unixParams ( ) ; $ output = [ ] ; $ return_var = 0 ; exec ( $ this -> the_command , $ output , $ return_var ) ; if ( $ return_var !== 0 ) { throw new Exception ( 'Your report has an error and couldn\'t be processed! Try to output the command: ' . escapeshellcmd ( $ this -> the_co... | Make report . |
4,076 | protected function unixParams ( ) { if ( $ this -> windows ) { return ; } $ this -> the_command .= $ this -> redirect_output ? ' > /dev/null 2>&1' : '' ; $ this -> the_command .= $ this -> background ? ' &' : '' ; $ this -> the_command = $ this -> run_as_user ? 'su -u ' . $ this -> run_as_user . ' -c "' . $ this -> the... | Set optional Unix parameters |
4,077 | public function filter ( $ value ) { if ( $ this -> encodingFormat !== null ) { $ firstChar = mb_substr ( $ value , 0 , 1 , $ this -> encodingFormat ) ; $ rest = mb_substr ( $ value , 1 , null , $ this -> encodingFormat ) ; return mb_strtoupper ( $ firstChar , $ this -> encodingFormat ) . $ rest ; } $ firstChar = mb_su... | Uppercase the first character of the value |
4,078 | public function send ( MessagebirdMessage $ message ) { if ( empty ( $ message -> originator ) ) { $ message -> setOriginator ( config ( 'services.messagebird.originator' ) ) ; } if ( empty ( $ message -> recipients ) ) { $ message -> setRecipients ( config ( 'services.messagebird.recipients' ) ) ; } if ( empty ( $ mes... | Send the Message . |
4,079 | public function filter ( $ value ) { if ( $ this -> encodingFormat !== null ) { return mb_strtolower ( $ value , $ this -> encodingFormat ) ; } return mb_strtolower ( $ value ) ; } | Lowercase the given value |
4,080 | public function filter ( $ value ) { if ( $ value === null ) { return $ value ; } if ( $ this -> characters === null ) { return trim ( $ value ) ; } return trim ( $ value , $ this -> characters ) ; } | Trim the value if no characters to trim are given use the PHP default |
4,081 | public function filter ( $ value ) { if ( $ this -> toEncoding === null ) { return $ value ; } if ( $ this -> fromEncoding === null ) { return mb_convert_encoding ( $ value , $ this -> toEncoding ) ; } return mb_convert_encoding ( $ value , $ this -> toEncoding , $ this -> fromEncoding ) ; } | Changes encoding of the value |
4,082 | public static function setSandbox ( $ sandbox ) { if ( $ sandbox == true ) { static :: setEnvironment ( Environment :: SANDBOX ) ; } else { static :: setEnvironment ( Environment :: PRODUCTION ) ; } } | Sets the sandbox . |
4,083 | public static function setEnvironment ( $ environment ) { if ( ! empty ( $ environment ) ) { foreach ( array_values ( static :: $ registeredInstances ) as $ instance ) { $ instance -> setEnvironment ( $ environment ) ; } static :: $ ENVIRONMENT = $ environment ; } } | This method is used to set the SubDomain |
4,084 | public static function registerResourceConfig ( $ instance ) { $ className = get_class ( $ instance ) ; if ( ! array_key_exists ( $ className , static :: $ registeredInstances ) ) { static :: $ registeredInstances [ '$className' ] = $ instance ; } } | This is used to add the SDKCOnfig to the APIConfig so when the configuration changes the underline SDKConfig are updated . |
4,085 | public static function subMap ( & $ inputMap , $ keyList ) { $ subMap = array ( ) ; foreach ( $ keyList as $ key ) { if ( array_key_exists ( $ key , $ inputMap ) ) { $ subMap [ $ key ] = $ inputMap [ $ key ] ; unset ( $ inputMap [ $ key ] ) ; } } return $ subMap ; } | This method is used to generate a sumMap by taking a subset of the map which contains the key specified in the list |
4,086 | public static function getNonce ( $ length = 16 ) { $ characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ; $ charactersLength = strlen ( $ characters ) ; $ randomString = '' ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ randomString .= $ characters [ rand ( 0 , $ charactersLength - 1 ) ] ; ... | Generate a Nonce string |
4,087 | public function decorateResponse ( Request $ request , Response $ response ) { if ( $ request -> headers -> has ( self :: ORIGIN_REQUEST_HEADER ) ) { $ request -> headers -> set ( 'referer' , $ request -> headers -> get ( self :: ORIGIN_REQUEST_HEADER ) ) ; } $ this -> setTurbolinksLocationHeaderFromSession ( $ request... | Modifies the HTTP headers and status code of the Response so that it can be properly handled by the Turbolinks javascript . |
4,088 | private function canHandleRedirect ( Request $ request ) { $ session = $ request -> getSession ( ) ; return ( is_a ( $ session , '\Symfony\Component\HttpFoundation\Session\SessionInterface' ) || is_a ( $ session , '\Illuminate\Contracts\Session\Session' ) ) && $ request -> headers -> has ( self :: ORIGIN_REQUEST_HEADER... | Checks if the request can handle a Turbolink redirect . You need to have a session and a XHR request header to handle a redirect . |
4,089 | private function getUrlOrigin ( $ url ) { return array ( parse_url ( $ url , PHP_URL_SCHEME ) , parse_url ( $ url , PHP_URL_HOST ) , parse_url ( $ url , PHP_URL_PORT ) , ) ; } | Parse the given url into an origin array with the scheme host and port . |
4,090 | private function haveSameOrigin ( Request $ request , Response $ response ) { $ requestOrigin = $ this -> getUrlOrigin ( $ request -> headers -> get ( self :: ORIGIN_REQUEST_HEADER ) ) ; $ responseOrigin = $ this -> getUrlOrigin ( $ response -> headers -> get ( self :: ORIGIN_RESPONSE_HEADER ) ) ; return $ requestOrigi... | Checks if the request and the response have the same origin . |
4,091 | private function modifyStatusCode ( Request $ request , Response $ response ) { if ( $ request -> headers -> has ( self :: ORIGIN_REQUEST_HEADER ) && $ response -> headers -> has ( self :: ORIGIN_RESPONSE_HEADER ) && ! $ this -> haveSameOrigin ( $ request , $ response ) ) { $ response -> setStatusCode ( Response :: HTT... | Modifies the response status code . Checks for cross domain redirects and blocks them . |
4,092 | public function createSendGridMailer ( $ username , $ password , $ options ) { if ( ! $ username ) { throw new InvalidConfigException ( "Username cannot be empty." ) ; } if ( ! $ password ) { throw new InvalidConfigException ( "Password cannot be empty." ) ; } $ sendgrid = new \ SendGrid ( $ username , $ password , $ o... | Create send grid mail instance |
4,093 | public function getFieldLayouts ( & $ context ) { $ context [ 'fieldLayouts' ] = [ ] ; foreach ( $ context [ 'fields' ] as $ field ) { $ layouts = [ ] ; foreach ( $ this -> _getRelatedLayoutIds ( $ field ) as $ row ) { $ layouts [ ] = $ this -> _getLayoutData ( $ row ) ; } $ context [ 'fieldLayouts' ] [ ] = [ 'field' =... | Collect all layouts based on existing fields . |
4,094 | private function _getRelatedLayoutIds ( $ field ) { return ( new Query ( ) ) -> select ( [ 'layoutId' , 'tabId' ] ) -> from ( [ '{{%fieldlayoutfields}}' ] ) -> where ( 'fieldId=:id' , [ ':id' => $ field -> id ] ) -> orderBy ( 'layoutId ASC' ) -> all ( ) ; } | Get partial data for all layouts which contain the specified field . |
4,095 | public function asObject ( string $ className , array $ constructorArgs = [ ] ) : QueryBuilderHandler { return $ this -> setFetchMode ( PDO :: FETCH_CLASS , $ className , $ constructorArgs ) ; } | Fetch query results as object of specified type |
4,096 | protected function aggregate ( string $ type , string $ field = '*' ) : float { if ( $ field !== '*' && isset ( $ this -> statements [ 'selects' ] ) === true && \ in_array ( $ field , $ this -> statements [ 'selects' ] , true ) === false ) { throw new ColumnNotFoundException ( sprintf ( 'Failed to count query - the col... | Performs special queries like COUNT SUM etc based on the current query . |
4,097 | public function getAlias ( ) : ? string { return isset ( $ this -> statements [ 'aliases' ] ) === true ? array_values ( $ this -> statements [ 'aliases' ] ) [ 0 ] : null ; } | Get the alias for the current query |
4,098 | public function getTable ( ) : ? string { if ( isset ( $ this -> statements [ 'tables' ] ) === true ) { $ table = array_values ( $ this -> statements [ 'tables' ] ) [ 0 ] ; if ( $ table instanceof Raw === false ) { return $ table ; } } return null ; } | Get the table - name for the current query |
4,099 | public function first ( ) { $ result = $ this -> limit ( 1 ) -> get ( ) ; return ( $ result !== null && \ count ( $ result ) !== 0 ) ? $ result [ 0 ] : null ; } | Returns the first row |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.