idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
41,900 | public static function frequency ( $ values ) { $ frequency = [ ] ; foreach ( $ values as $ value ) { if ( is_float ( $ value ) ) { $ value = strval ( $ value ) ; } if ( ! isset ( $ frequency [ $ value ] ) ) { $ frequency [ $ value ] = 1 ; } else { $ frequency [ $ value ] += 1 ; } } asort ( $ frequency ) ; return $ fre... | Calculates the frequency table for a given set of values . |
41,901 | public static function mode ( $ values ) { $ frequency = self :: frequency ( $ values ) ; if ( count ( $ frequency ) === 1 ) { return key ( $ frequency ) ; } $ lastTwo = array_slice ( $ frequency , - 2 , 2 , true ) ; $ firstFrequency = current ( $ lastTwo ) ; $ lastFrequency = next ( $ lastTwo ) ; if ( $ firstFrequency... | Calculates the mode for a given set of values . |
41,902 | public static function variance ( $ values , $ sample = true ) { $ numberOfValues = count ( $ values ) ; $ mean = self :: mean ( $ values ) ; $ squaredDifferences = [ ] ; foreach ( $ values as $ value ) { $ squaredDifferences [ ] = self :: squaredDifference ( $ value , $ mean ) ; } $ sumOfSquaredDifferences = self :: s... | Calculates the variance for a given set of values . |
41,903 | private function convertToExtendedFieldQuery ( ) { $ this -> fieldModel = $ this -> dispatcher -> getContainer ( ) -> get ( 'mautic.lead.model.field' ) ; $ this -> selectParts = $ this -> query -> getQueryPart ( 'select' ) ; $ this -> orderByParts = $ this -> query -> getQueryPart ( 'orderBy' ) ; $ this -> groupByParts... | helper method to convert queries with extendedField optins in select orderBy and GroupBy to work with the extendedField schema . |
41,904 | public function getExtendedFields ( ) { $ result = [ ] ; $ fields = $ this -> getEntities ( [ 'filter' => [ 'where' => [ [ 'expr' => 'orX' , 'val' => [ [ 'column' => 'f.object' , 'expr' => 'eq' , 'value' => 'extendedField' ] , [ 'column' => 'f.object' , 'expr' => 'eq' , 'value' => 'extendedFieldSecure' ] , ] , ] , ] , ... | Method used to get a whitelist of extended fields for query consideration . |
41,905 | public function getEntities ( array $ args = [ ] ) { $ replacementFilter = [ 'column' => 'f.object' , 'expr' => 'neq' , 'value' => [ 'company' ] , ] ; foreach ( $ args as $ type => & $ arg ) { if ( 'filter' === $ type ) { foreach ( $ arg as $ key => & $ filter ) { if ( 'force' === $ key ) { foreach ( $ filter as $ forc... | Returns lead custom fields . |
41,906 | public function saveEntity ( $ entity , $ unlock = true ) { if ( ! $ this -> isExtendedField ( $ entity ) ) { parent :: saveEntity ( $ entity , $ unlock ) ; return ; } if ( ! $ entity instanceof LeadField ) { throw new MethodNotAllowedHttpException ( [ 'LeadEntity' ] ) ; } $ isNew = $ entity -> getId ( ) ? false : true... | Save an extended field . |
41,907 | public function getLookupResults ( $ type , $ filter = '' , $ limit = 10 ) { return $ this -> getRepository ( ) -> getValueList ( $ type , $ filter , $ limit ) ; } | Get list of custom field values for autopopulate fields . |
41,908 | protected function addCatchAllWhereClause ( $ q , $ filter ) { $ filterContainsPhone = $ this -> filterContainsPhone ( $ filter ) ; $ filterContainsEmail = $ this -> filterContainsEmail ( $ filter ) ; $ filterContainsZip = $ this -> filterContainsZip ( $ filter ) ; $ columns = array_merge ( $ filterContainsPhone , $ fi... | Adds the catch all where clause to the QueryBuilder . |
41,909 | private function getExtendedFieldValuesMultiple ( $ extendedFieldList = [ ] , $ leadIds = [ ] ) { $ em = $ this -> getEntityManager ( ) ; $ leadIdsStr = "'" . implode ( "','" , $ leadIds ) . "'" ; $ selects = [ ] ; foreach ( [ 'string' , 'float' , 'boolean' , 'date' , 'datetime' , 'time' , 'text' ] as $ data_type ) { f... | Join all the EAV data into one consumable array . |
41,910 | private function getExtendedFieldFilters ( $ args , $ extendedFieldList ) { $ result = [ ] ; if ( isset ( $ args [ 'filter' ] ) ) { foreach ( array_keys ( $ extendedFieldList ) as $ alias ) { if ( isset ( $ args [ 'filter' ] [ 'string' ] ) && ( ( is_string ( $ args [ 'filter' ] [ 'string' ] ) && false !== strpos ( $ ar... | Discern search filters that are bound to extended fields . |
41,911 | private function getExtendedField ( $ alias ) { $ qf = $ this -> _em -> getConnection ( ) -> createQueryBuilder ( ) ; $ qf -> select ( 'lf.id, lf.object, lf.type, lf.alias, lf.field_group as "group", lf.object, lf.label' ) -> from ( MAUTIC_TABLE_PREFIX . 'lead_fields' , 'lf' ) -> where ( $ qf -> expr ( ) -> andX ( $ qf... | Get an extended field given the field alias . |
41,912 | protected function valueToDateTime ( $ date ) { if ( ! $ date instanceof \ DateTime ) { $ date = is_int ( $ date ) ? \ DateTime :: createFromFormat ( 'U' , $ date ) : new \ DateTime ( ( string ) $ date ) ; } return $ date ; } | Turn a value into a DateTime object |
41,913 | protected function getDateFormatter ( $ dateFormat , $ timeFormat , $ calendar ) { $ datetype = isset ( $ dateFormat ) ? $ this -> getFormat ( $ dateFormat ) : null ; $ timetype = isset ( $ timeFormat ) ? $ this -> getFormat ( $ timeFormat ) : null ; $ calendarConst = $ calendar === 'traditional' ? \ IntlDateFormatter ... | Get configured intl date formatter . |
41,914 | public function localDate ( $ date , $ format = null , $ calendar = 'gregorian' ) { return $ this -> formatLocal ( $ date , $ format , false , $ calendar ) ; } | Format the date value as a string based on the current locale |
41,915 | public function localTime ( $ date , $ format = 'short' , $ calendar = 'gregorian' ) { return $ this -> formatLocal ( $ date , false , $ format , $ calendar ) ; } | Format the time value as a string based on the current locale |
41,916 | protected function splitDuration ( $ seconds , $ max ) { if ( $ max < 1 || $ seconds < 60 ) { return [ $ seconds ] ; } $ minutes = floor ( $ seconds / 60 ) ; $ seconds = $ seconds % 60 ; if ( $ max < 2 || $ minutes < 60 ) { return [ $ seconds , $ minutes ] ; } $ hours = floor ( $ minutes / 60 ) ; $ minutes = $ minutes ... | Split duration into seconds minutes hours days weeks and years . |
41,917 | public function duration ( $ value , $ units = [ 's' , 'm' , 'h' , 'd' , 'w' , 'y' ] , $ separator = ' ' ) { if ( ! isset ( $ value ) ) { return null ; } list ( $ seconds , $ minutes , $ hours , $ days , $ weeks , $ years ) = $ this -> splitDuration ( $ value , count ( $ units ) - 1 ) + array_fill ( 0 , 6 , null ) ; $ ... | Calculate duration from seconds . One year is seen as exactly 52 weeks . |
41,918 | protected function assertNoEval ( $ pattern ) { $ pos = strrpos ( $ pattern , $ pattern [ 0 ] ) ; $ modifiers = substr ( $ pattern , $ pos + 1 ) ; if ( strpos ( $ modifiers , 'e' ) !== false ) { throw new \ Twig_Error_Runtime ( "Using the eval modifier for regular expressions is not allowed" ) ; } } | Check that the regex doesn t use the eval modifier |
41,919 | public function get ( $ value , $ pattern , $ group = 0 ) { if ( ! isset ( $ value ) ) { return null ; } return preg_match ( $ pattern , $ value , $ matches ) && isset ( $ matches [ $ group ] ) ? $ matches [ $ group ] : null ; } | Perform a regular expression match and return a matched group . |
41,920 | public function getAll ( $ value , $ pattern , $ group = 0 ) { if ( ! isset ( $ value ) ) { return null ; } return preg_match_all ( $ pattern , $ value , $ matches , PREG_PATTERN_ORDER ) && isset ( $ matches [ $ group ] ) ? $ matches [ $ group ] : [ ] ; } | Perform a regular expression match and return the group for all matches . |
41,921 | public function grep ( $ values , $ pattern , $ flags = '' ) { if ( ! isset ( $ values ) ) { return null ; } if ( is_string ( $ flags ) ) { $ flags = $ flags === 'invert' ? PREG_GREP_INVERT : 0 ; } return preg_grep ( $ pattern , $ values , $ flags ) ; } | Perform a regular expression match and return an array of entries that match the pattern |
41,922 | public function line ( $ value , $ line = 1 ) { if ( ! isset ( $ value ) ) { return null ; } $ lines = explode ( "\n" , $ value ) ; return isset ( $ lines [ $ line - 1 ] ) ? $ lines [ $ line - 1 ] : null ; } | Get a single line |
41,923 | public function less ( $ value , $ replace = '...' , $ break = '<!-- pagebreak ) { if ( ! isset ( $ value ) ) { return null ; } $ pos = stripos ( $ value , $ break ) ; return $ pos === false ? $ value : substr ( $ value , 0 , $ pos ) . $ replace ; } | Cut of text on a pagebreak . |
41,924 | public function truncate ( $ value , $ length , $ replace = '...' ) { if ( ! isset ( $ value ) ) { return null ; } return strlen ( $ value ) <= $ length ? $ value : substr ( $ value , 0 , $ length - strlen ( $ replace ) ) . $ replace ; } | Cut of text if it s to long . |
41,925 | protected function linkifyMail ( $ text , array & $ links , $ attr ) { $ regexp = '~([^\s<>]+?@[^\s<>]+?\.[^\s<>]+)(?<![\.,:;\?!\'"\|])~' ; return preg_replace_callback ( $ regexp , function ( $ match ) use ( & $ links , $ attr ) { return '<' . array_push ( $ links , '<a' . $ attr . ' href="mailto:' . $ match [ 1 ] . '... | Linkify a mail link . |
41,926 | protected function linkifyOther ( $ protocol , $ text , array & $ links , $ attr , $ mode ) { if ( strpos ( $ protocol , ':' ) === false ) { $ protocol .= in_array ( $ protocol , [ 'ftp' , 'tftp' , 'ssh' , 'scp' ] ) ? '://' : ':' ; } $ regexp = $ mode != 'all' ? '~' . preg_quote ( $ protocol , '~' ) . '([^\s<>]+)(?<![\... | Linkify a link . |
41,927 | public function linkify ( $ value , $ protocols = [ 'http' , 'mail' ] , array $ attributes = [ ] , $ mode = 'normal' ) { if ( ! isset ( $ value ) ) { return null ; } $ attr = '' ; foreach ( $ attributes as $ key => $ val ) { $ attr .= ' ' . $ key . '="' . htmlentities ( $ val ) . '"' ; } $ links = [ ] ; $ text = preg_r... | Turn all URLs in clickable links . |
41,928 | public function htmlAttributes ( $ array ) { if ( ! isset ( $ array ) ) { return null ; } $ str = "" ; foreach ( $ array as $ key => $ value ) { if ( ! isset ( $ value ) || $ value === false ) { continue ; } if ( $ value === true ) { $ value = $ key ; } $ str .= ' ' . $ key . '="' . addcslashes ( $ value , '"' ) . '"' ... | Cast an array to an HTML attribute string |
41,929 | public function setDefaultQueue ( $ name ) { if ( ! $ this -> hasQueue ( $ name ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown queue "%s"' , $ name ) ) ; } $ this -> defaultQueue = $ name ; return $ this ; } | Sets default queue |
41,930 | public function putCheck ( $ check , $ queueName = null ) { if ( $ queueName === null ) { if ( $ this -> defaultQueue === null ) { throw new \ LogicException ( 'Default queue is not set' ) ; } $ queueName = $ this -> defaultQueue ; } if ( ! $ this -> hasQueue ( $ queueName ) ) { throw new \ InvalidArgumentException ( s... | Sends a check to queue |
41,931 | public function isQueueActive ( $ name ) { if ( ! $ this -> hasQueue ( $ name ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown queue "%s"' , $ name ) ) ; } $ path = sprintf ( 'api/shop/v1/queues/%s' , $ this -> queues [ $ name ] ) ; $ data = $ this -> client -> sendRequest ( $ path ) ; return is_array ( ... | Whether queue active |
41,932 | public function getItems ( ) { $ items = parent :: getItems ( ) ; if ( ( $ items instanceof ArrayList ) && ! empty ( $ this -> rawSubmittal ) ) { $ sortLookup = array_flip ( $ this -> rawSubmittal ) ; $ itemsArray = $ items -> toArray ( ) ; usort ( $ itemsArray , function ( $ itemA , $ itemB ) use ( $ sortLookup ) { if... | Return the files in sorted order |
41,933 | protected function sortManyManyRelation ( ManyManyList $ relation , array $ idList , array $ rawList , DataObjectInterface $ record , $ sortColumn ) { $ relation -> getForeignID ( ) ; $ ownerIdField = $ relation -> getForeignKey ( ) ; $ fileIdField = $ relation -> getLocalKey ( ) ; $ joinTable = '"' . $ relation -> get... | Apply sorting to a many_many relation |
41,934 | protected function sortManyManyThroughRelation ( ManyManyThroughList $ relation , array $ idList , array $ rawList , $ sortColumn ) { $ relation -> getForeignID ( ) ; $ dataQuery = $ relation -> dataQuery ( ) ; $ manipulators = $ dataQuery -> getDataQueryManipulators ( ) ; $ manyManyManipulator = null ; foreach ( $ man... | Apply sorting to a many_many_through relation |
41,935 | public function onPostAutoloadDump ( Event $ event ) { $ args = $ event -> isDevMode ( ) ? '' : ' --no-dev' ; $ finder = new ExecutableFinder ( ) ; $ hhvm = $ finder -> find ( 'hhvm' , 'hhvm' ) ; $ executor = new ProcessExecutor ( $ this -> io ) ; $ command = $ hhvm . ' ' . ProcessExecutor :: escape ( $ this -> vendor ... | Callback for after the main composer autoload map has been updated . |
41,936 | public function addChildCData ( $ name , $ cdata_text ) { $ child = $ this -> addChild ( $ name ) ; $ child -> addCData ( $ cdata_text ) ; } | Create a child with CDATA value |
41,937 | public static function underscore ( $ string = null ) { if ( $ string === null ) { return null ; } return strtolower ( preg_replace ( '/([A-Z])/' , '_\1' , lcfirst ( $ string ) ) ) ; } | Underscore a string . |
41,938 | public function setupDefaults ( $ layoutId = 1 ) { $ layoutService = CpNav :: $ plugin -> layoutService ; $ navigationService = CpNav :: $ plugin -> navigationService ; if ( ! $ layoutService -> getById ( $ layoutId ) ) { $ layoutService -> setDefaultLayout ( $ layoutId ) ; } $ navService = new Cp ( ) ; $ defaultNavs =... | Create the default Layout after plugin is installed |
41,939 | public function regenerateNav ( $ layoutId , $ generatedNav , $ currentNav ) { if ( count ( $ generatedNav ) < count ( $ currentNav ) ) { $ order = 0 ; foreach ( $ currentNav as $ value ) { if ( isset ( $ value [ 'url' ] ) ) { $ handle = str_replace ( UrlHelper :: url ( ) . '/' , '' , $ value [ 'url' ] ) ; } else { $ h... | Creates or deletes records when the menu is updated by plugins |
41,940 | public function update ( ) { $ update_url = 'https://raw.github.com/ai/autoprefixer-rails/master/vendor/autoprefixer.js' ; $ local_path = __DIR__ . '/vendor/autoprefixer.js' ; $ new = file_get_contents ( $ update_url ) ; $ old = file_get_contents ( $ local_path ) ; if ( md5 ( $ new ) == md5 ( $ old ) ) return false ; f... | Download autoprefixer updates . |
41,941 | public function buildValidator ( Event $ event , Validator $ validator , $ name ) { foreach ( ( array ) $ this -> getConfig ( 'displayField' ) as $ field ) { if ( strpos ( $ field , '.' ) === false ) { $ validator -> requirePresence ( $ field , 'create' ) -> notEmpty ( $ field ) ; } } } | Callback for Model . buildValidator event . |
41,942 | public function beforeSave ( Event $ event , Entity $ entity , ArrayObject $ options ) { $ onUpdate = $ this -> getConfig ( 'onUpdate' ) ; if ( ! $ entity -> isNew ( ) && ! $ onUpdate ) { return ; } $ onDirty = $ this -> getConfig ( 'onDirty' ) ; $ field = $ this -> getConfig ( 'field' ) ; if ( ! $ onDirty && $ entity ... | Callback for Model . beforeSave event . |
41,943 | protected function _getPartsFromEntity ( $ entity ) { $ parts = [ ] ; foreach ( ( array ) $ this -> getConfig ( 'displayField' ) as $ displayField ) { $ value = Hash :: get ( $ entity , $ displayField ) ; if ( $ value === null && ! $ entity -> isNew ( ) ) { return [ ] ; } if ( ! empty ( $ value ) || is_numeric ( $ valu... | Gets the parts from an entity |
41,944 | public function findSlugged ( Query $ query , array $ options ) { if ( ! isset ( $ options [ 'slug' ] ) ) { throw new InvalidArgumentException ( 'The `slug` key is required by the `slugged` finder.' ) ; } return $ query -> where ( [ $ this -> _table -> aliasField ( $ this -> getConfig ( 'field' ) ) => $ options [ 'slug... | Custom finder . |
41,945 | public function slug ( $ entity , $ string = null , $ separator = null ) { if ( $ separator === null ) { $ separator = $ this -> getConfig ( 'separator' ) ; } if ( is_string ( $ entity ) ) { if ( $ string !== null ) { $ separator = $ string ; } $ string = $ entity ; unset ( $ entity ) ; } elseif ( ( $ entity instanceof... | Generates slug . |
41,946 | protected function _getSlugStringFromEntity ( $ entity , $ separator ) { $ string = [ ] ; foreach ( ( array ) $ this -> getConfig ( 'displayField' ) as $ field ) { if ( $ entity -> getError ( $ field ) ) { throw new InvalidArgumentException ( sprintf ( 'Error while generating the slug, the field `%s` contains an invali... | Gets the slug string based on an entity |
41,947 | protected function _conditions ( $ entity , $ slug ) { $ primaryKey = $ this -> _table -> getPrimaryKey ( ) ; $ field = $ this -> _table -> aliasField ( $ this -> getConfig ( 'field' ) ) ; $ conditions = [ $ field => $ slug ] ; if ( is_callable ( $ this -> getConfig ( 'scope' ) ) ) { $ scope = $ this -> getConfig ( 'sc... | Builds the conditions |
41,948 | protected function _uniqueSlug ( Entity $ entity , $ slug , $ separator ) { $ primaryKey = $ this -> _table -> getPrimaryKey ( ) ; $ field = $ this -> _table -> aliasField ( $ this -> getConfig ( 'field' ) ) ; $ conditions = $ this -> _conditions ( $ entity , $ slug ) ; $ i = 0 ; $ suffix = '' ; $ length = $ this -> ge... | Returns a unique slug . |
41,949 | protected function _slug ( $ string , $ separator ) { $ replacements = $ this -> getConfig ( 'replacements' ) ; $ callable = $ this -> slugger ( ) ; if ( is_object ( $ callable ) && $ callable instanceof SluggerInterface ) { $ callable = [ $ callable , 'slug' ] ; } $ slug = $ callable ( str_replace ( array_keys ( $ rep... | Proxies the defined slugger s slug method . |
41,950 | public function generate ( $ bits = 50.0 ) { $ bits = ( float ) $ bits ; $ separators = $ this -> getSeparators ( ) ; $ separatorBits = $ this -> precisionFloat ( log ( strlen ( $ separators ) , 2 ) ) ; $ passPhrase = '' ; try { if ( $ bits < self :: MIN_ENTROPY_BITS || $ bits > self :: MAX_ENTROPY_BITS ) { throw new \... | Generates a passphrase based on supplied wordlists separators entropy bits and word modifier . |
41,951 | public function makesSenseToUseSeparators ( $ bits , $ wordBits , $ separatorBits ) { $ wordCount = 1 + ( $ bits + ( ( $ wordBits + $ separatorBits - 1 ) - $ wordBits ) ) / ( $ wordBits + $ separatorBits ) ; return ( ( int ) ( ( $ bits + ( $ wordBits - 1 ) ) / $ wordBits ) !== ( int ) $ wordCount ) ; } | Detects whether it is sensible to use separator characters . |
41,952 | public function getRandomBytes ( $ count ) { $ count = ( int ) $ count ; $ bytes = '' ; $ hasBytes = false ; if ( version_compare ( PHP_VERSION , '7.0.0' ) >= 0 && function_exists ( 'random_bytes' ) ) { try { $ bytes = \ random_bytes ( $ count ) ; $ hasBytes = true ; } catch ( \ Exception $ e ) { } } if ( version_compa... | Generate a random string of bytes . |
41,953 | public function publish_update ( $ topic_urls , $ http_function = false ) { if ( ! isset ( $ topic_urls ) ) { throw new InvalidArgumentException ( 'Please specify a topic url' ) ; } if ( ! is_array ( $ topic_urls ) ) { $ topic_urls = [ $ topic_urls ] ; } $ post_string = 'hub.mode=publish' ; foreach ( $ topic_urls as $ ... | Accepts either a single url or an array of urls . |
41,954 | public function lock ( string $ id , bool $ blocking = true , int $ limit = 300 ) : void { $ this -> autoCreateIndexes && $ this -> createIndexes ( ) ; if ( $ limit > $ this -> limit ) { throw new \ LogicException ( 'The limit could not be greater than a default one. The default is used to set an expiration index' ) ; ... | Limit is in seconds |
41,955 | public function saveAsFile ( $ diagram , $ savePath ) { if ( is_dir ( $ savePath ) ) { $ filePath = $ savePath . '/' . $ this -> cleanFileName ( $ diagram -> id ) . '.bpmn' ; } else { $ filePath = './' . $ this -> cleanFileName ( $ diagram -> id ) . '.bpmn' ; } $ handle = fopen ( $ filePath , 'c+' ) ; ftruncate ( $ han... | saves the bpmn diagram as file . |
41,956 | public static function verifyMessageSignature ( $ secret , $ body = null , $ signature = null ) { $ body = is_null ( $ body ) ? file_get_contents ( 'php://input' ) : $ body ; $ hash = base64_encode ( hash_hmac ( 'sha256' , $ body , $ secret , true ) ) ; $ signature = is_null ( $ signature ) ? $ _SERVER [ 'HTTP_X_ACUITY... | Verify a message signature using your API key . |
41,957 | public static function getInstance ( $ appId , $ testMode = false , $ cache = false , $ compression = false ) { if ( ! isset ( self :: $ instances [ $ appId ] ) ) { $ config = new Config ( $ appId ) ; $ config -> setTestMode ( $ testMode ) ; $ config -> setCache ( $ cache ) ; $ config -> setCompression ( $ compression ... | Ziska sdilenou instanci Skautis objektu |
41,958 | public function done ( $ result = null , \ Exception $ e = null ) { $ this -> time += microtime ( true ) ; $ this -> result = $ result ; $ this -> exception = $ e ; return $ this ; } | Oznac pozadavek za dokonceny a uloz vysledek |
41,959 | final public static function toOAuth2 ( ServerRequestInterface $ request ) { $ contents = $ request -> getBody ( ) -> getContents ( ) ; $ request -> getBody ( ) -> rewind ( ) ; return new OAuth2 \ Request ( ( array ) $ request -> getQueryParams ( ) , ( array ) $ request -> getParsedBody ( ) , $ request -> getAttributes... | Returns a new instance of \ OAuth2 \ Request based on the given \ Slim \ Http \ Request |
41,960 | private static function cleanupHeaders ( array $ uncleanHeaders = [ ] ) { $ cleanHeaders = [ ] ; $ headerMap = [ 'Php-Auth-User' => 'PHP_AUTH_USER' , 'Php-Auth-Pw' => 'PHP_AUTH_PW' , 'Php-Auth-Digest' => 'PHP_AUTH_DIGEST' , 'Auth-Type' => 'AUTH_TYPE' , 'HTTP_AUTHORIZATION' => 'AUTHORIZATION' , ] ; foreach ( $ uncleanHe... | Helper method to clean header keys and values . |
41,961 | final public static function fromOauth2 ( OAuth2 \ Response $ oauth2Response ) { $ headers = [ ] ; foreach ( $ oauth2Response -> getHttpHeaders ( ) as $ key => $ value ) { $ headers [ $ key ] = explode ( ', ' , $ value ) ; } $ stream = fopen ( 'php://temp' , 'r+' ) ; if ( ! empty ( $ oauth2Response -> getParameters ( )... | Copies values from the given Oauth2 \ Response to a PSR - 7 Http Response . |
41,962 | public static function sanitizeIp ( $ ipString ) { $ ipString = trim ( $ ipString ) ; $ posSlash = strrpos ( $ ipString , '/' ) ; if ( $ posSlash !== false ) { $ ipString = substr ( $ ipString , 0 , $ posSlash ) ; } $ posColon = strrpos ( $ ipString , ':' ) ; $ posDot = strrpos ( $ ipString , '.' ) ; if ( $ posColon !=... | Removes the port and the last portion of a CIDR IP address . |
41,963 | public static function getIPRangeBounds ( $ ipRange ) { if ( strpos ( $ ipRange , '/' ) === false ) { $ ipRange = self :: sanitizeIpRange ( $ ipRange ) ; if ( $ ipRange === null ) { return null ; } } $ pos = strpos ( $ ipRange , '/' ) ; $ bits = substr ( $ ipRange , $ pos + 1 ) ; $ range = substr ( $ ipRange , 0 , $ po... | Get low and high IP addresses for a specified IP range . |
41,964 | public static function fromBinaryIP ( $ ip ) { if ( $ ip === null || $ ip === '' ) { return new IPv4 ( "\x00\x00\x00\x00" ) ; } if ( self :: isIPv4 ( $ ip ) ) { return new IPv4 ( $ ip ) ; } return new IPv6 ( $ ip ) ; } | Factory method to create an IP instance from an IP in binary format . |
41,965 | public function getHostname ( ) { $ stringIp = $ this -> toString ( ) ; $ host = strtolower ( @ gethostbyaddr ( $ stringIp ) ) ; if ( $ host === '' || $ host === $ stringIp ) { return null ; } return $ host ; } | Tries to return the hostname associated to the IP . |
41,966 | public function renderAsTable ( ) { $ html = '' ; foreach ( $ this -> cells as $ iRow => $ rowCells ) { $ rowHtml = '' ; foreach ( $ rowCells as $ iCol => $ cell ) { $ rowHtml .= $ cell -> render ( ) ; } $ html .= ' <tr>' . $ rowHtml . '</tr>' . "\n" ; } return "<table>\n <tbody>\n" . $ html . " </tbody>\n</table>... | Renders the inner html of the table section . |
41,967 | protected function validate ( $ key , $ value ) { if ( ! isset ( $ this -> defaults [ $ key ] ) ) { $ factory_method = 'get_' . $ key ; if ( ! method_exists ( $ this , $ factory_method ) ) { throw new MiniContainerException ( sprintf ( 'Unknown key "%s"' , $ key ) ) ; } } $ validate_method = 'validate_' . $ key ; if ( ... | Validates a value before it is being set . |
41,968 | protected function valueForKey ( $ key ) { $ method = 'get_' . $ key ; if ( ! method_exists ( $ this , $ method ) ) { if ( isset ( $ this -> defaults [ $ key ] ) ) { return $ this -> defaults [ $ key ] ; } throw new MiniContainerException ( sprintf ( 'Unknown key "%s".' , $ key ) ) ; } return $ this -> $ method ( ) ; } | Determines a value for the given key . |
41,969 | function setColOrder ( $ orderedBaseColNames , $ groupPrefix = null ) { $ this -> columns -> setOrder ( $ orderedBaseColNames , $ groupPrefix ) ; return $ this ; } | Sets the order for all columns or column groups at the top level or at a the relative top level within one group . |
41,970 | private function internalAddName ( $ name ) { $ this -> children [ $ name ] = array ( ) ; if ( false !== $ pos = strrpos ( $ name , '.' ) ) { $ parentName = substr ( $ name , 0 , $ pos ) ; if ( ! isset ( $ this -> children [ $ parentName ] ) ) { $ this -> internalAddName ( $ parentName ) ; } $ this -> parents [ $ name ... | Adds a name from which we know already it does not exist . This allows to avoid redundant checks when called internally . |
41,971 | function setOrder ( array $ orderedNames , $ parentName = null ) { if ( isset ( $ parentName ) ) { if ( ! isset ( $ this -> children [ $ parentName ] ) ) { throw new \ Exception ( "Unknown name '$parentName'." ) ; } $ this -> children [ $ parentName ] = $ this -> internalSetOrder ( $ this -> children [ $ parentName ] ,... | Sets the order for all children of a parent or all toplevel names . This operation cannot add or remove names only reorder them . If names would be added or removed an exception is thrown instead . |
41,972 | public function send ( \ Swift_Mime_SimpleMessage $ message , & $ failedRecipients = null ) : int { self :: $ deliveredMessages [ ] = $ message ; $ this -> systemLogger -> log ( 'Sent email to ' . $ this -> buildStringFromEmailAndNameArray ( $ message -> getTo ( ) ) , LOG_DEBUG , [ 'message' => $ message -> toString ( ... | Send the given Message . This transport will add it to a stored collection of sent messages for testing purposes and log the message to the system logger . |
41,973 | protected function buildStringFromEmailAndNameArray ( array $ addresses ) : string { $ results = [ ] ; foreach ( $ addresses as $ emailAddress => $ name ) { if ( $ name !== '' ) { $ results [ ] = sprintf ( '%s <%s>' , $ name , $ emailAddress ) ; } else { $ results [ ] = $ emailAddress ; } } return implode ( ', ' , $ re... | Builds a plaintext - compatible string representing an array of given E - Mail addresses . |
41,974 | public function create ( string $ transportType , array $ transportOptions = [ ] , array $ transportArguments = null ) : \ Swift_Transport { if ( ! class_exists ( $ transportType ) ) { throw new Exception ( sprintf ( 'The specified transport backend "%s" does not exist.' , $ transportType ) , 1269351207 ) ; } if ( is_a... | Factory method which creates the specified transport with the given options . |
41,975 | public function send ( \ Swift_Mime_SimpleMessage $ message , & $ failedRecipients = null ) { $ message -> generateId ( ) ; $ mboxFrom = $ this -> getReversePath ( $ message ) ; $ mboxDate = strftime ( '%c' , $ message -> getDate ( ) -> getTimestamp ( ) ) ; $ messageString = sprintf ( 'From %s %s' , $ mboxFrom , $ mbox... | Outputs the mail to a text file according to RFC 4155 . |
41,976 | public function setFile ( string $ filePath ) : self { if ( ! file_exists ( $ filePath ) ) { throw new MimeDetectorException ( "File '" . $ filePath . "' does not exist." ) ; } $ this -> stream = $ this -> readFile ( $ filePath ) ; $ this -> createByteCache ( ) ; return $ this ; } | Setter for the file to be checked . |
41,977 | protected function checkString ( string $ str , int $ offset = 0 ) : bool { return $ this -> checkForBytes ( $ this -> toBytes ( $ str ) , $ offset ) ; } | Checks the byte sequence of a given string . |
41,978 | protected function searchForBytes ( array $ bytes , int $ offset = 0 , array $ mask = [ ] ) : int { $ limit = $ this -> byteCacheLen - count ( $ bytes ) ; for ( $ i = $ offset ; $ i < $ limit ; $ i ++ ) { if ( $ this -> checkForBytes ( $ bytes , $ i , $ mask ) ) { return $ i ; } } return - 1 ; } | Returns the offset to the next position of the given byte sequence . Returns - 1 if the sequence was not found . |
41,979 | protected function checkForBytes ( array $ bytes , int $ offset = 0 , array $ mask = [ ] ) : bool { if ( empty ( $ bytes ) || empty ( $ this -> byteCache ) ) { return false ; } $ bytes = array_values ( $ bytes ) ; foreach ( $ bytes as $ i => $ byte ) { if ( ! empty ( $ mask ) ) { if ( ! isset ( $ this -> byteCache [ $ ... | Returns true if a given byte sequence is found at the given offset within the given file . |
41,980 | public function loadYamlFile ( $ filename ) { if ( ! file_exists ( $ filename ) ) { $ this -> output -> writeln ( "<error>The file $filename does not exist.</error>" ) ; return false ; } try { $ contents = Yaml :: parse ( file_get_contents ( $ filename ) ) ; } catch ( \ Exception $ e ) { $ this -> output -> writeln ( "... | Loads a yaml file . |
41,981 | public function writeYamlFile ( $ filename , $ data ) { try { $ yaml = Yaml :: dump ( $ data -> export ( ) , 3 , 2 ) ; } catch ( \ Exception $ e ) { $ this -> output -> writeln ( "<error>There was an error dumping the YAML contents for $filename.</error>" ) ; $ this -> output -> writeln ( $ e -> getMessage ( ) ) ; retu... | Writes YAML data to a file . |
41,982 | protected function checkKeyExists ( $ data , $ key ) { if ( ! $ data -> has ( $ key ) ) { $ this -> output -> writeln ( "<error>The key $key does not exist." ) ; return false ; } return true ; } | Checks if a key exists in an array . |
41,983 | protected function cleanUpValue ( $ value ) { $ cleanValue = [ ] ; if ( ! is_array ( $ value ) ) { return $ cleanValue ; } foreach ( $ value as $ singleValue ) { $ singleValue = parent :: cleanUpValue ( $ singleValue ) ; if ( ! isset ( $ this -> fields [ $ singleValue ] ) ) { continue ; } $ cleanValue [ ] = $ singleVal... | Clean up incoming value . |
41,984 | protected function updateTitle ( ) { $ title = $ this -> getTitle ( ) ; if ( $ title !== null ) { if ( method_exists ( $ this , 'formatTitleWithAccessKey' ) ) { $ title = $ this -> formatTitleWithAccessKey ( $ title ) ; } $ this -> titled -> setAttributes ( [ 'title' => $ title ] ) ; } else { $ this -> titled -> remove... | Update the title attribute in case of changes to title or accessKey . |
41,985 | public function setSelected ( $ state ) { $ this -> selected = ( bool ) $ state ; if ( $ this -> selected ) { $ this -> input -> setAttributes ( [ 'checked' => 'checked' ] ) ; } else { $ this -> input -> removeAttributes ( [ 'checked' ] ) ; } return $ this ; } | Set selection state of this checkbox . |
41,986 | public function updateElementClasses ( Element $ element ) { $ classes = $ this -> getElementClasses ( $ element ) ; if ( method_exists ( $ element , 'getIconElement' ) ) { $ element -> getIconElement ( ) -> removeClasses ( $ classes [ 'off' ] ) -> addClasses ( $ classes [ 'on' ] ) ; } if ( method_exists ( $ element , ... | Update CSS classes provided by the theme . |
41,987 | public function setTabIndex ( $ tabIndex ) { $ tabIndex = preg_match ( '/^-?\d+$/' , $ tabIndex ) ? ( int ) $ tabIndex : null ; if ( $ this -> tabIndex !== $ tabIndex ) { $ this -> tabIndex = $ tabIndex ; $ this -> updateTabIndex ( ) ; } return $ this ; } | Set tab index value . |
41,988 | public function updateTabIndex ( ) { $ disabled = $ this -> isDisabled ( ) ; if ( $ this -> tabIndex !== null ) { $ this -> tabIndexed -> setAttributes ( [ 'tabindex' => $ disabled ? - 1 : $ this -> tabIndex , 'aria-disabled' => ( $ disabled ? 'true' : 'false' ) ] ) ; } else { $ this -> tabIndexed -> removeAttributes (... | Update the tabIndex attribute in case of changes to tabIndex or disabled state . |
41,989 | public function setIcon ( $ icon = null ) { if ( $ this -> iconName !== null ) { $ this -> icon -> removeClasses ( [ 'oo-ui-icon-' . $ this -> iconName ] ) ; } if ( $ icon !== null ) { $ this -> icon -> addClasses ( [ 'oo-ui-icon-' . $ icon ] ) ; } $ this -> iconName = $ icon ; $ this -> toggleClasses ( [ 'oo-ui-iconEl... | Set icon name . |
41,990 | public function setReadOnly ( $ state ) { $ this -> readOnly = ( bool ) $ state ; if ( $ this -> readOnly ) { $ this -> input -> setAttributes ( [ 'readonly' => 'readonly' ] ) ; } else { $ this -> input -> removeAttributes ( [ 'readonly' ] ) ; } return $ this ; } | Set the read - only state of the widget . This should probably change the widget s appearance and prevent it from being used . |
41,991 | public function setRequired ( $ state ) { $ this -> required = ( bool ) $ state ; if ( $ this -> required ) { $ this -> input -> setAttributes ( [ 'required' => 'required' , 'aria-required' => 'true' ] ) ; if ( $ this -> getIndicator ( ) === null ) { $ this -> setIndicator ( 'required' ) ; } } else { $ this -> input ->... | Set the required state of the widget . |
41,992 | public function setDisabled ( $ disabled ) { $ this -> disabled = ( bool ) $ disabled ; $ this -> toggleClasses ( [ 'oo-ui-widget-disabled' ] , $ this -> disabled ) ; $ this -> toggleClasses ( [ 'oo-ui-widget-enabled' ] , ! $ this -> disabled ) ; $ this -> setAttributes ( [ 'aria-disabled' => $ this -> disabled ? 'true... | Set the disabled state of the widget . |
41,993 | public function setHref ( $ href ) { $ this -> href = is_string ( $ href ) ? $ href : null ; $ this -> updateHref ( ) ; return $ this ; } | Set hyperlink location . |
41,994 | public function updateHref ( ) { if ( $ this -> href !== null && ! $ this -> isDisabled ( ) ) { $ this -> button -> setAttributes ( [ 'href' => $ this -> href ] ) ; } else { $ this -> button -> removeAttributes ( [ 'href' ] ) ; } return $ this ; } | Update the href attribute in case of changes to href or disabled state . |
41,995 | public function setTarget ( $ target ) { $ this -> target = is_string ( $ target ) ? $ target : null ; if ( $ this -> target !== null ) { $ this -> button -> setAttributes ( [ 'target' => $ target ] ) ; } else { $ this -> button -> removeAttributes ( [ 'target' ] ) ; } return $ this ; } | Set hyperlink target . |
41,996 | public function setNoFollow ( $ noFollow ) { $ this -> noFollow = is_bool ( $ noFollow ) ? $ noFollow : true ; if ( $ this -> noFollow ) { $ this -> button -> setAttributes ( [ 'rel' => 'nofollow' ] ) ; } else { $ this -> button -> removeAttributes ( [ 'rel' ] ) ; } return $ this ; } | Set search engine traversal hint . |
41,997 | public function setActive ( $ active = null ) { $ this -> active = ( bool ) $ active ; $ this -> toggleClasses ( [ 'oo-ui-buttonElement-active' ] , $ this -> active ) ; return $ this ; } | Toggle active state . |
41,998 | public function setLabel ( $ label ) { if ( $ this -> useInputTag ) { if ( ! is_string ( $ label ) ) { $ label = '' ; } $ this -> input -> setValue ( $ label ) ; } return $ this -> setLabelElementLabel ( $ label ) ; } | Set label value . |
41,999 | public function addTabPanels ( array $ tabPanels ) { $ tabItems = [ ] ; foreach ( $ tabPanels as $ i => $ tabPanel ) { $ this -> tabPanels [ $ tabPanel -> getName ( ) ] = $ tabPanel ; $ labelElement = new Tag ( 'span' ) ; $ tabItem = new TabOptionWidget ( [ 'labelElement' => $ labelElement , 'label' => $ tabPanel -> ge... | Add tab panels to the index layout |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.