idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
3,600 | public function darken ( Color $ color , $ amount = null ) { $ current = $ color -> lightness ; $ amount = ( $ amount === null ) ? self :: DEFAULT_ADJUST : $ amount ; $ amount = intval ( $ amount ) / 100 ; $ new = $ current - $ amount ; $ new = ( $ new < 0 ) ? 0 : $ new ; $ new = ( $ new > 1 ) ? 1 : $ new ; $ color -> ... | Darkens color by a percentage a given Color object |
3,601 | public function merge ( Color $ color1 , Color $ color2 , $ percentage = 50 ) { return new Color ( array ( 'red' => $ this -> getMergedColorPart ( 'red' , $ color1 , $ color2 , $ percentage ) , 'green' => $ this -> getMergedColorPart ( 'green' , $ color1 , $ color2 , $ percentage ) , 'blue' => $ this -> getMergedColorP... | Merges the current color with a second color with an optional percentage |
3,602 | public static function getMapStyleJSON ( ) { $ folders = [ 'client/dist/js/' , 'client/dist/javascript/' , 'dist/js/' , 'dist/javascript/' , 'src/javascript/thirdparty' , 'js/' , 'javascript/' , ] ; $ file = 'mapStyle.json' ; foreach ( $ folders as $ folder ) { if ( $ style = ThemeResourceLoader :: inst ( ) -> findThem... | Gets the style of the map |
3,603 | public static function getIconImage ( $ svg = true ) { $ folders = [ 'client/dist/img/' , 'client/dist/images/' , 'dist/img/' , 'dist/images/' , 'img/' , 'images/' , ] ; $ extensions = [ 'png' , 'jpg' , 'jpeg' , 'gif' , ] ; if ( $ svg === true ) { array_unshift ( $ extensions , 'svg' ) ; } $ file = 'mapIcon' ; foreach ... | Gets the maker icon image |
3,604 | public function isAddressChanged ( $ level = 1 ) { $ fields = [ 'Address' , 'Address2' , 'City' , 'State' , 'PostalCode' , 'Country' ] ; $ changed = $ this -> owner -> getChangedFields ( false , $ level ) ; foreach ( $ fields as $ field ) { if ( array_key_exists ( $ field , $ changed ) ) { return true ; } } return fals... | Returns TRUE if any of the address fields have changed . |
3,605 | private function writeTracks ( \ XMLWriter $ xmlWriter , Workout $ workout ) { $ xmlWriter -> startElement ( 'Activities' ) ; foreach ( $ workout -> tracks ( ) as $ track ) { $ xmlWriter -> startElement ( 'Activity' ) ; $ xmlWriter -> writeAttribute ( 'Sport' , ucfirst ( $ track -> sport ( ) ) ) ; $ xmlWriter -> writeE... | Write the tracks to the TCX . |
3,606 | private function writeTrackPoints ( \ XMLWriter $ xmlWriter , array $ trackPoints ) { $ previousTrackPoint = null ; foreach ( $ trackPoints as $ trackPoint ) { $ xmlWriter -> startElement ( 'Trackpoint' ) ; $ dateTime = clone $ trackPoint -> dateTime ( ) ; $ dateTime -> setTimezone ( new \ DateTimeZone ( 'UTC' ) ) ; $ ... | Write the track points to the TCX . |
3,607 | protected function writeLapHeartRateDate ( \ XMLWriter $ xmlWriter , Track $ track ) { $ averageHeartRate = array ( ) ; $ maxHearRate = null ; foreach ( $ track -> trackPoints ( ) as $ trackPoint ) { if ( $ trackPoint -> hasExtension ( HR :: ID ( ) ) === true ) { $ pointHearRate = $ trackPoint -> extension ( HR :: ID (... | Write the heart rate data for a lap . |
3,608 | protected function writeExtensions ( \ XMLWriter $ xmlWriter , array $ extensions ) { foreach ( $ extensions as $ extension ) { switch ( $ extension :: ID ( ) ) { case HR :: ID ( ) : $ xmlWriter -> startElement ( 'HeartRateBpm' ) ; $ xmlWriter -> writeElement ( 'Value' , ( string ) $ extension -> value ( ) ) ; $ xmlWri... | Write the extensions into the TCX . |
3,609 | protected function cleanToken ( ) { if ( $ token_name = $ this -> getToken ( ) ) { $ path = substr ( $ this -> path , strlen ( $ token_name ) ) ; return preg_replace ( '/<.*>/' , '' , $ path ) ; } $ message = sprintf ( 'No token could be found in "%s". Available tokens are: %s.' , $ this -> path , implode ( ', ' , arra... | Removes the token from the tokenized path . |
3,610 | protected function getToken ( ) { foreach ( array_keys ( $ this -> supportedTokens ) as $ token_name ) { if ( strpos ( $ this -> path , $ token_name ) !== FALSE ) { return $ token_name ; } } return NULL ; } | Checks if the current tokenized path contains a known token . |
3,611 | protected function parseArguments ( ) { $ token_name = $ this -> getToken ( ) ; $ delimiter = '/' ; $ matches = array ( ) ; if ( preg_match ( $ delimiter . preg_quote ( $ token_name ) . '<(.+)>.*' . $ delimiter , $ this -> path , $ matches ) ) { return explode ( ',' , $ matches [ 1 ] ) ; } return array ( ) ; } | Gets the arguments in the token . |
3,612 | private function arrayFrom ( $ requestMethod ) : array { if ( is_string ( $ requestMethod ) ) { return [ $ requestMethod ] ; } if ( null === $ requestMethod ) { return [ Http :: GET , Http :: HEAD , Http :: POST , Http :: PUT , Http :: DELETE ] ; } if ( is_array ( $ requestMethod ) ) { return $ requestMethod ; } throw ... | turns given value into a list |
3,613 | public function matches ( CalledUri $ calledUri ) : bool { if ( ! $ this -> matchesPath ( $ calledUri ) ) { return false ; } if ( in_array ( $ calledUri -> method ( ) , $ this -> allowedRequestMethods ) ) { return true ; } if ( in_array ( Http :: GET , $ this -> allowedRequestMethods ) ) { return $ calledUri -> methodE... | checks if this route is applicable for given request |
3,614 | public function preIntercept ( $ preInterceptor ) : ConfigurableRoute { if ( ! is_callable ( $ preInterceptor ) && ! ( $ preInterceptor instanceof PreInterceptor ) && ! class_exists ( ( string ) $ preInterceptor ) ) { throw new \ InvalidArgumentException ( 'Given pre interceptor must be a callable, an instance of ' . P... | add a pre interceptor for this route |
3,615 | public function postIntercept ( $ postInterceptor ) : ConfigurableRoute { if ( ! is_callable ( $ postInterceptor ) && ! ( $ postInterceptor instanceof PostInterceptor ) && ! class_exists ( ( string ) $ postInterceptor ) ) { throw new \ InvalidArgumentException ( 'Given pre interceptor must be a callable, an instance of... | add a post interceptor for this route |
3,616 | public function requiresHttps ( ) : bool { if ( $ this -> requiresHttps ) { return true ; } $ this -> requiresHttps = $ this -> routingAnnotations ( ) -> requiresHttps ( ) ; return $ this -> requiresHttps ; } | whether route is only available via https |
3,617 | public function authConstraint ( ) : AuthConstraint { if ( null === $ this -> authConstraint ) { $ this -> authConstraint = new AuthConstraint ( $ this -> routingAnnotations ( ) ) ; } return $ this -> authConstraint ; } | returns auth constraint for this route |
3,618 | public function supportsMimeType ( string $ mimeType , string $ class = null ) : ConfigurableRoute { if ( null === $ class && ! SupportedMimeTypes :: provideDefaultClassFor ( $ mimeType ) ) { throw new \ InvalidArgumentException ( 'No default class known for mime type ' . $ mimeType . ', please provide a class' ) ; } $... | add a mime type which this route supports |
3,619 | public function supportedMimeTypes ( array $ globalMimeTypes = [ ] , array $ globalClasses = [ ] ) : SupportedMimeTypes { if ( $ this -> disableContentNegotation || $ this -> routingAnnotations ( ) -> isContentNegotiationDisabled ( ) ) { return SupportedMimeTypes :: createWithDisabledContentNegotation ( ) ; } return ne... | returns list of mime types supported by this route |
3,620 | private function routingAnnotations ( ) : RoutingAnnotations { if ( null === $ this -> routingAnnotations ) { $ this -> routingAnnotations = new RoutingAnnotations ( $ this -> target ) ; } return $ this -> routingAnnotations ; } | returns list of callback annotations |
3,621 | public function asResource ( HttpUri $ uri , array $ globalMimeTypes = [ ] ) : Resource { $ routeUri = $ uri -> withPath ( $ this -> normalizePath ( ) ) ; return new Resource ( $ this -> resourceName ( ) , $ this -> allowedRequestMethods , $ this -> requiresHttps ( ) ? $ routeUri -> toHttps ( ) : $ routeUri , $ this ->... | returns route as resource |
3,622 | private function normalizePath ( ) : string { $ path = $ this -> path ; if ( substr ( $ path , - 1 ) === '$' ) { $ path = substr ( $ path , 0 , strlen ( $ path ) - 1 ) ; } if ( substr ( $ path , - 1 ) === '?' ) { $ path = substr ( $ path , 0 , strlen ( $ path ) - 1 ) ; } return $ path ; } | normalizes path for better understanding |
3,623 | private function resourceName ( ) { if ( $ this -> routingAnnotations ( ) -> hasName ( ) ) { return $ this -> routingAnnotations ( ) -> name ( ) ; } if ( is_string ( $ this -> target ) && class_exists ( $ this -> target ) ) { return substr ( $ this -> target , strrpos ( $ this -> target , '\\' ) + 1 ) ; } elseif ( ! is... | returns useful name for resource |
3,624 | public function registerXPathNamespace ( $ prefix , $ uri ) { $ this -> el -> registerXPathNamespace ( $ prefix , $ uri ) ; $ this -> namespaces [ $ prefix ] = $ uri ; } | Register a new xpath namespace . |
3,625 | public function registerXPathNamespaces ( $ namespaces ) { foreach ( $ namespaces as $ prefix => $ uri ) { $ this -> registerXPathNamespace ( $ prefix , $ uri ) ; } } | Register an array of new xpath namespaces . |
3,626 | public function children ( $ ns = null ) { $ ch = is_null ( $ ns ) ? $ this -> el -> children ( ) : $ this -> el -> children ( $ this -> namespaces [ $ ns ] ) ; $ o = [ ] ; foreach ( $ ch as $ c ) { $ o [ ] = new static ( $ c , $ this ) ; } return $ o ; } | Returns child elements . |
3,627 | public function attributes ( $ ns = null , $ is_prefix = false ) { return $ this -> el -> attributes ( $ ns , $ is_prefix ) ; } | Returns and element s attributes . |
3,628 | protected static function handleDELETE ( $ parameters , $ method , $ headers , $ id , $ modelClass , $ primaryDataParameters = [ ] , $ validationCallbacks = [ ] , $ viewCallback = null ) { if ( $ viewCallback !== null && ! is_callable ( $ viewCallback ) ) { throw new ServerException ( 'View callback is not callable!' )... | Handle DELETE method On success will respond with 204 No Content |
3,629 | public function setupMustache ( ) { $ mustacheLoader = new MustacheLoader ( $ this -> viewManager ) ; $ config = [ 'loader' => $ mustacheLoader ] ; if ( $ this -> viewManager -> cachePath ) { $ config [ 'cache' ] = $ this -> viewManager -> cachePath . 'mustache/' ; } $ this -> mustache = new Mustache_Engine ( $ config ... | Sets up Mustache_Engine |
3,630 | public function preBuild ( ) { $ build_path = $ this -> getBuildPath ( ) ; if ( $ build_path ) { if ( is_dir ( $ build_path ) ) { $ build_path = rtrim ( $ build_path , DIRECTORY_SEPARATOR ) ; if ( ! is_dir ( "$build_path/Manager/Base" ) ) { $ old_umask = umask ( 0 ) ; $ dir_created = mkdir ( "$build_path/Manager/Base" ... | Execute prior to type build . |
3,631 | public function add ( string $ name , $ value ) : self { $ this -> headers [ $ name ] = $ value ; return $ this ; } | adds header with given name |
3,632 | public function location ( $ uri ) : self { return $ this -> add ( 'Location' , ( ( $ uri instanceof HttpUri ) ? ( $ uri -> asStringWithNonDefaultPort ( ) ) : ( $ uri ) ) ) ; } | adds location header with given uri |
3,633 | public function acceptable ( array $ supportedMimeTypes ) : self { if ( count ( $ supportedMimeTypes ) > 0 ) { $ this -> add ( 'X-Acceptable' , join ( ', ' , $ supportedMimeTypes ) ) ; } return $ this ; } | adds non - standard acceptable header with list of supported mime types |
3,634 | public function cacheControl ( ) : CacheControl { $ cacheControl = new CacheControl ( ) ; $ this -> add ( CacheControl :: HEADER_NAME , $ cacheControl ) ; return $ cacheControl ; } | enables the Cache - Control header |
3,635 | protected function collectNormalBelongsToRelationAccessors ( ) { $ accessors = [ ] ; foreach ( $ this -> data [ 'relationships' ] [ 'normal' ] as $ name => $ relationship ) { if ( $ relationship [ 'type' ] != Generator :: RELATIONSHIP_BELONGS_TO ) continue ; if ( ! empty ( $ relationship [ 'key' ] ) && snake_case ( $ n... | For belongs - to relationships that share foreign key & relation name |
3,636 | public function getDeviceForRequest ( WURFL_Request_GenericRequest $ request ) { $ deviceId = $ this -> deviceIdForRequest ( $ request ) ; return $ this -> getWrappedDevice ( $ deviceId , $ request ) ; } | Returns the Device for the given WURFL_Request_GenericRequest |
3,637 | public function fromRelationshipType ( $ type ) { $ relationships = $ this -> getRelationshipsThatMatchType ( $ type ) ; if ( count ( $ relationships ) === 0 ) { return null ; } $ resource = reset ( $ relationships ) ; return new RelationshipResource ( key ( $ relationships ) , $ resource ) ; } | Get a resource from just the relationship type . |
3,638 | protected function getRelationshipsThatMatchType ( $ type ) { return array_filter ( $ this -> mapRelationshipsToIdAndData ( ) , function ( $ relationship ) use ( $ type ) { $ relationshipType = Arr :: get ( $ relationship , 'type' ) ; return Str :: snakeCase ( $ type ) === Str :: snakeCase ( $ relationshipType ) ; } ) ... | Get all the relationships that their type matches the given type . |
3,639 | protected function getRelationshipResourceForReference ( $ fullRelationshipReference ) { $ relationshipParts = explode ( '.' , $ fullRelationshipReference ) ; if ( count ( $ relationshipParts ) !== 3 ) { return null ; } if ( $ this -> resourceType ( ) !== array_shift ( $ relationshipParts ) ) { return null ; } $ relati... | Get a relationship resource for a fully qualified reference . |
3,640 | public function setStateListener ( $ event , $ listener ) { $ js = sprintf ( 'uLogin.setStateListener("%s", "%s", %s);' , $ this -> id , $ event , $ listener ) ; $ this -> getView ( ) -> registerJs ( $ js ) ; return $ this ; } | Sets the event handler in the event ulogin |
3,641 | public function call ( array $ params ) { $ this -> initResolver ( ) ; $ defaults = array_merge ( array ( 'format' => $ this -> format ) , $ this -> defaultParams ) ; $ this -> resolver -> setDefaults ( $ defaults ) ; $ this -> resolver -> setMandatory ( array ( 'module' => 'API' , 'method' => $ this -> name ( ) ) ) ; ... | calls piwik api |
3,642 | public function dropSchemaFor ( StreamName $ streamName , $ returnSql = false ) { $ dropTable = new DropTable ( $ this -> getTable ( $ streamName ) ) ; if ( $ returnSql ) { return $ dropTable -> getSqlString ( $ this -> dbAdapter -> getPlatform ( ) ) ; } $ this -> dbAdapter -> getDriver ( ) -> getConnection ( ) -> exec... | Drops a stream table |
3,643 | protected function insertEvent ( StreamName $ streamName , DomainEvent $ e ) { $ eventData = array ( 'event_id' => $ e -> uuid ( ) -> toString ( ) , 'version' => $ e -> version ( ) , 'event_name' => $ e -> messageName ( ) , 'event_class' => get_class ( $ e ) , 'payload' => Serializer :: serialize ( $ e -> payload ( ) ,... | Insert an event |
3,644 | protected function getTablegateway ( StreamName $ streamName ) { if ( ! isset ( $ this -> tableGateways [ $ streamName -> toString ( ) ] ) ) { $ this -> tableGateways [ $ streamName -> toString ( ) ] = new TableGateway ( $ this -> getTable ( $ streamName ) , $ this -> dbAdapter ) ; } return $ this -> tableGateways [ $ ... | Get the corresponding Tablegateway of the given stream name |
3,645 | protected function getTable ( StreamName $ streamName ) { if ( isset ( $ this -> streamTableMap [ $ streamName -> toString ( ) ] ) ) { $ tableName = $ this -> streamTableMap [ $ streamName -> toString ( ) ] ; } else { $ tableName = strtolower ( $ this -> getShortStreamName ( $ streamName ) ) ; if ( strpos ( $ tableName... | Get table name for given stream name |
3,646 | private function read ( ) { if ( $ this -> request -> hasParam ( $ this -> sessionName ) ) { return $ this -> request -> readParam ( $ this -> sessionName ) -> ifMatches ( self :: SESSION_ID_REGEX ) ; } elseif ( $ this -> request -> hasCookie ( $ this -> sessionName ) ) { return $ this -> request -> readCookie ( $ this... | reads session id |
3,647 | public function regenerate ( ) : SessionId { $ this -> id = $ this -> create ( ) ; $ this -> response -> addCookie ( Cookie :: create ( $ this -> sessionName , $ this -> id ) -> forPath ( '/' ) ) ; return $ this ; } | stores session id for given session name |
3,648 | public static function render ( SQL \ Aliased $ aliased ) { $ content = $ aliased -> getContent ( ) ; if ( $ content instanceof Query \ Select ) { $ content = "(" . Select :: render ( $ content ) . ")" ; } else { $ content = Compiler :: name ( $ content ) ; } return Compiler :: expression ( array ( $ content , Compiler... | Render SQL for Aliased |
3,649 | public function interceptMethodCall ( ProceedingJoinPointInterface $ jointPoint ) { $ time = $ this -> monitor -> getTime ( ) ; if ( $ this -> namePrefix ) { $ name = $ this -> namePrefix ; } else { $ name = get_class ( $ jointPoint -> getTarget ( ) ) ; } if ( $ this -> metricPerMethod ) { $ name .= '.' . $ jointPoint ... | In this implementation we measure time and count every method call |
3,650 | protected function setValue ( $ value ) { if ( is_string ( $ value ) ) { $ this -> value = $ value ; } else { throw new \ InvalidArgumentException ( "Invalid type '" . gettype ( $ value ) . "' for argument 'value' given." ) ; } return $ this ; } | Sets the condition value . |
3,651 | public function getUser ( ) { $ resource = '/users/' . $ this -> userId ; $ response = $ this -> makeAuthenticatedApiRequest ( $ resource ) ; return $ response -> user ; } | get a user |
3,652 | public function getBadges ( ) { $ uri = $ this -> buildUserResourceUri ( 'badges' ) ; $ response = $ this -> makeAuthenticatedApiRequest ( $ uri ) ; return $ response -> badges ; } | Returns badges for a given user . |
3,653 | public function getCheckins ( array $ options = array ( ) ) { $ uri = $ this -> buildUserResourceUri ( 'checkins' ) ; $ response = $ this -> makeAuthenticatedApiRequest ( $ uri , $ options ) ; return $ response -> checkins -> items ; } | Returns a history of checkins for the authenticated user . |
3,654 | public function getFriends ( array $ options = array ( ) ) { $ uri = $ this -> buildUserResourceUri ( 'friends' ) ; $ response = $ this -> makeAuthenticatedApiRequest ( $ uri , $ options ) ; return $ response -> friends -> items ; } | Returns an array of a user s friends . |
3,655 | public function getTips ( array $ options = array ( ) ) { $ uri = $ this -> buildUserResourceUri ( 'tips' ) ; $ response = $ this -> makeAuthenticatedApiRequest ( $ uri , $ options ) ; return $ response -> tips -> items ; } | Returns an array of a user s tips . |
3,656 | public function getLists ( array $ options = array ( ) ) { $ uri = $ this -> buildUserResourceUri ( 'lists' ) ; $ response = $ this -> makeAuthenticatedApiRequest ( $ uri , $ options ) ; return $ response -> lists ; } | A User s Lists . |
3,657 | public function getMayorships ( ) { $ uri = $ this -> buildUserResourceUri ( 'mayorships' ) ; $ response = $ this -> makeAuthenticatedApiRequest ( $ uri ) ; return $ response -> mayorships -> items ; } | Returns a user s mayorships . |
3,658 | public function getPhotos ( array $ options = array ( ) ) { $ uri = $ this -> buildUserResourceUri ( 'photos' ) ; $ response = $ this -> makeAuthenticatedApiRequest ( $ uri ) ; return $ response -> photos -> items ; } | Returns photos from a user . |
3,659 | public function getVenueHistory ( array $ options = array ( ) ) { $ uri = $ this -> buildUserResourceUri ( 'venuehistory' ) ; $ response = $ this -> makeAuthenticatedApiRequest ( $ uri ) ; return $ response -> venues -> items ; } | Returns a list of all venues visited by the specified user along with how many visits and when they were last there . |
3,660 | public function approve ( $ friendId ) { $ uri = $ this -> buildUserResourceUri ( 'approve' , $ friendId ) ; $ response = $ this -> makeAuthenticatedApiRequest ( $ uri ) ; return $ response -> user ; } | Approves a pending friend request from another user . |
3,661 | public function deny ( $ friendId ) { $ uri = $ this -> buildUserResourceUri ( 'deny' , $ friendId ) ; $ response = $ this -> makeAuthenticatedApiRequest ( $ uri ) ; return $ response -> user ; } | Denies a pending friend request from another user . |
3,662 | public function request ( $ friendId ) { $ uri = $ this -> buildUserResourceUri ( 'request' , $ friendId ) ; $ response = $ this -> makeAuthenticatedApiRequest ( $ uri ) ; return $ response -> user ; } | Sends a friend request to another user . If the other user is a page then the requesting user will automatically start following the page . |
3,663 | public function unfriend ( $ friendId ) { $ uri = $ this -> buildUserResourceUri ( 'unfriend' , $ friendId ) ; $ response = $ this -> makeAuthenticatedApiRequest ( $ uri ) ; return $ response -> user ; } | Cancels any relationship between the acting user and the specified user Removes a friend unfollows a celebrity or cancels a pending friend request . |
3,664 | protected function buildUserResourceUri ( $ resource , $ userId = null ) { $ userId = is_null ( $ userId ) ? $ this -> userId : $ userId ; return '/users/' . $ userId . '/' . $ resource ; } | build the resource URI |
3,665 | public function & offsetGet ( $ n ) { if ( ! $ this -> offsetExists ( $ n ) ) { throw new IndexNotFoundException ( ( string ) $ n ) ; } return $ this -> data [ $ n ] ; } | Get the nth entry . |
3,666 | public function addPoint ( array $ point ) { if ( ! isset ( $ point [ 1 ] ) ) { $ point = array ( time ( ) , $ point [ 0 ] ) ; } if ( ! is_integer ( $ point [ 0 ] ) ) { throw new InvalidPointException ( 'Timestamp must be an integer' ) ; } if ( ! is_int ( $ point [ 1 ] ) && ! is_float ( $ point [ 1 ] ) ) { throw new In... | Add a new measure point to the metric . |
3,667 | public function changeExtension ( $ extension ) { $ pathname = $ this -> createPathname ( $ this -> getPath ( ) , $ this -> getBasename ( ) , $ extension ) ; return new static ( $ pathname ) ; } | Changes file extension . |
3,668 | protected function initializeBinding ( Binding $ binding ) { $ binding -> initialize ( $ this -> getBindingType ( $ binding -> getTypeName ( ) ) ) ; $ bindingClass = get_class ( $ binding ) ; if ( ! isset ( $ this -> initializersByBindingClass [ $ bindingClass ] ) ) { $ this -> initializersByBindingClass [ $ bindingCla... | Initializes a binding . |
3,669 | public function getAdditionalProperties ( ) { if ( $ this -> decoded_additional_properties === false ) { $ raw = trim ( $ this -> getRawAdditionalProperties ( ) ) ; $ this -> decoded_additional_properties = empty ( $ raw ) ? [ ] : json_decode ( $ raw , true ) ; if ( ! is_array ( $ this -> decoded_additional_properties ... | Return additional log properties as array . |
3,670 | public function & setAdditionalProperties ( array $ value = null ) { $ this -> decoded_additional_properties = false ; $ this -> setRawAdditionalProperties ( json_encode ( $ value ) ) ; return $ this ; } | Set attributes value . |
3,671 | public function getAdditionalProperty ( $ name , $ default = null ) { $ additional_properties = $ this -> getAdditionalProperties ( ) ; return $ additional_properties && isset ( $ additional_properties [ $ name ] ) ? $ additional_properties [ $ name ] : $ default ; } | Returna attribute value . |
3,672 | protected function checkFloatTypes ( NumericTypeInterface $ a , NumericTypeInterface $ b ) { $ a1 = ( $ a instanceof FloatType ? $ a : $ a -> asFloatType ( ) ) ; $ b1 = ( $ b instanceof FloatType ? $ b : $ b -> asFloatType ( ) ) ; return [ $ a1 , $ b1 ] ; } | Check for float type converting if necessary |
3,673 | protected function checkRationalTypes ( NumericTypeInterface $ a , NumericTypeInterface $ b ) { $ a1 = ( $ a instanceof RationalType ? $ a : $ a -> asRational ( ) ) ; $ b1 = ( $ b instanceof RationalType ? $ b : $ b -> asRational ( ) ) ; return [ $ a1 , $ b1 ] ; } | Check for rational type converting if necessary |
3,674 | public function matchParams ( array $ params ) { $ result = [ ] ; foreach ( $ this -> explodedParams as $ name => list ( $ default , $ pattern , $ patternName ) ) { if ( ! \ array_key_exists ( $ name , $ params ) ) { if ( \ is_null ( $ default ) ) { return false ; } $ currentParam = $ default ; } else { $ currentParam ... | Returns false or converted params |
3,675 | public function resolve ( DefinitionInterface $ definition ) { switch ( true ) { case $ definition instanceof ReferenceDefinitionInterface : return $ this -> container -> get ( $ definition -> getTarget ( ) ) ; case $ definition instanceof ParameterDefinitionInterface : return $ definition -> getValue ( ) ; case $ defi... | Resolve a definition and return the resulting value . |
3,676 | private function resolveSubDefinition ( $ value ) { if ( is_array ( $ value ) ) { return array_map ( [ $ this , 'resolveSubDefinition' ] , $ value ) ; } elseif ( $ value instanceof DefinitionInterface ) { return $ this -> resolve ( $ value ) ; } return $ value ; } | Resolve a variable that can be a sub - definition . |
3,677 | public function set ( string $ container , $ object , ConfigInterface $ config = null ) : ContainersInterface { if ( ! $ this -> has ( $ container ) ) { if ( \ is_object ( $ object ) ) { $ this -> setContainer ( $ container , $ object ) ; } else { $ class = '\\DrMVC\\' . $ object ; $ this -> setContainer ( $ container ... | PSR - 11 set container |
3,678 | protected function getControllerClass ( $ name ) { $ controllerClass = $ name ; if ( ! class_exists ( $ name ) ) { $ controllerClass = $ this -> controllerClasspath . '\\' . $ name ; if ( ! class_exists ( $ controllerClass ) ) { $ controllerClass = '\\FatPanda\\Illuminate\\WordPress\\Http\\Controllers\\' . $ name ; if ... | Given the classname of a controller seek out a proper namespace ; start with the set controller classpath then move on to the core default then try looking for the class without any classpath at all . |
3,679 | private function invokeControllerAction ( $ controllerClassNamed , $ actionNamed , array $ givenArgs = [ ] ) { if ( is_wp_error ( $ controllerClass = $ this -> getControllerClass ( $ controllerClassNamed ) ) ) { return $ controllerClass ; } $ reflection = new \ ReflectionClass ( $ controllerClass ) ; $ controller = new... | Invoke the given action on the given class after resolving an existing Class that matches the given class as named ; map arguments to controller action by dependency injection . |
3,680 | function resource ( $ name , $ controllerClass , $ options = [ ] ) { if ( empty ( $ options [ 'idString' ] ) ) { $ options [ 'idString' ] = '{id}' ; } $ actions = array_keys ( $ this -> resourceActions ) ; if ( ! empty ( $ options [ 'only' ] ) ) { $ actions = $ options [ 'only' ] ; } else if ( ! empty ( $ options [ 'ex... | Create a resource endpoint set bound to the given controller for handling all requests |
3,681 | public function unserialize ( $ data ) { $ injector = \ Injector :: inst ( ) ; $ extraData = null ; if ( empty ( self :: $ objectConstructorReflectionMethods [ __CLASS__ ] ) ) { self :: $ objectConstructorReflectionMethods [ __CLASS__ ] = new \ ReflectionMethod ( __CLASS__ , '__construct' ) ; } if ( empty ( self :: $ c... | This routine simulates what would happen when a object is constructed |
3,682 | public function add ( string $ rel , HttpUri $ uri ) : Link { $ link = new Link ( $ rel , $ uri ) ; if ( isset ( $ this -> links [ $ rel ] ) ) { if ( ! is_array ( $ this -> links [ $ rel ] ) ) { $ this -> links [ $ rel ] = [ $ this -> links [ $ rel ] ] ; } $ this -> links [ $ rel ] [ ] = $ link ; } else { $ this -> lin... | adds link to collection of links |
3,683 | public function with ( string $ rel ) : array { if ( isset ( $ this -> links [ $ rel ] ) ) { if ( is_array ( $ this -> links [ $ rel ] ) ) { return $ this -> links [ $ rel ] ; } return [ $ this -> links [ $ rel ] ] ; } return [ ] ; } | returns all links with given relation |
3,684 | public function getIterator ( ) : \ Traversable { $ result = [ ] ; foreach ( $ this -> links as $ link ) { if ( is_array ( $ link ) ) { $ result = array_merge ( $ result , $ link ) ; } else { $ result [ ] = $ link ; } } return new \ ArrayIterator ( $ result ) ; } | allows to iterate over all resources |
3,685 | private function registerServices ( ) { $ this -> app -> singleton ( 'pluggables' , function ( $ app ) { return new Pluggables ( $ app [ 'config' ] , $ app [ 'files' ] ) ; } ) ; $ this -> app -> booting ( function ( $ app ) { $ app [ 'pluggables' ] -> register ( ) ; } ) ; } | Register services of the package . |
3,686 | private function registerRepository ( ) { $ this -> app -> singleton ( 'migration.repository' , function ( $ app ) { $ table = $ app [ 'config' ] [ 'database.migrations' ] ; return new DatabaseMigrationRepository ( $ app [ 'db' ] , $ table ) ; } ) ; } | Register the repository service . |
3,687 | private function registerConsoleCommands ( ) { $ this -> registerMakeCommand ( ) ; $ this -> registerEnableCommand ( ) ; $ this -> registerDisableCommand ( ) ; $ this -> registerListCommand ( ) ; $ this -> registerMigrateCommand ( ) ; $ this -> registerMigrateRefreshCommand ( ) ; $ this -> registerMakeMigrationCommand ... | Register the package console commands . |
3,688 | public static function getPluginDirsInDir ( $ dir = null ) { if ( $ dir === null ) { $ dir = self :: $ config [ 'pluginspath' ] ; } $ plugin_dirs = array ( ) ; $ handle = opendir ( $ dir ) ; if ( $ handle ) { while ( $ plugin_dir = readdir ( $ handle ) ) { if ( substr ( $ plugin_dir , 0 , 1 ) !== '.' && is_dir ( $ dir ... | Returns a list of plugin directory names from a base directory . Copied from 1 . 9 core due to elgg_get_plugin_ids_in_dir removal in 1 . 9 |
3,689 | protected function createConsoleRequest ( ) : Request { $ requestStack = $ this -> getRequestStack ( ) ; $ request = $ requestStack -> getCurrentRequest ( ) ; if ( ! $ request instanceof Request ) { $ request = new Request ( ) ; $ requestStack -> push ( $ request ) ; } $ request -> attributes -> set ( 'pbjx_console' , ... | Some pbjx binders validators etc . expect a request to exist . Create one if nothing has been created yet . |
3,690 | public function lastTrackPoint ( ) : TrackPoint { $ lastTrackPoint = end ( $ this -> trackPoints ) ; if ( ! $ lastTrackPoint instanceof TrackPoint ) { throw new \ OutOfBoundsException ( 'No track points points defined.' ) ; } reset ( $ this -> trackPoints ) ; return $ lastTrackPoint ; } | Get the last track point . |
3,691 | public function duration ( ) { $ start = $ this -> startDateTime ( ) ; $ end = $ this -> endDateTime ( ) ; $ dateDifference = $ start -> diff ( $ end ) ; $ dateInterval = new DateInterval ( 'PT1S' ) ; $ dateInterval -> y = $ dateDifference -> y ; $ dateInterval -> m = $ dateDifference -> m ; $ dateInterval -> d = $ dat... | Get the duration of the track . |
3,692 | public function length ( ) : float { if ( $ this -> length === 0 ) { $ this -> length = $ this -> recomputeLength ( ) ; } return $ this -> length ; } | Get the length of the track in meters . |
3,693 | private function recomputeLength ( ) : float { $ this -> length = 0 ; $ trackPoints = $ this -> trackPoints ( ) ; $ trackPointsCount = count ( $ trackPoints ) ; if ( $ trackPointsCount < 2 ) { return 0 ; } for ( $ i = 1 ; $ i < $ trackPointsCount ; $ i ++ ) { $ previousTrack = $ trackPoints [ $ i - 1 ] ; $ currentTrack... | Recompute the length of the track . |
3,694 | public function verifyCode ( $ clientID , $ clientSecret , $ redirectURI , $ code ) { $ response = $ this -> get ( 'oauth2/access_token' , [ 'client_id' => $ clientID , 'client_secret' => $ clientSecret , 'grant_type' => 'authorization_code' , 'redirect_uri' => $ redirectURI , 'code' => $ code ] ) ; $ result = \ false ... | Second step of OAuth . This verifies the code obtained by the first function . If valid this function returns the user s access token which you need to save for all upcoming API requests . |
3,695 | private function setArray ( $ object ) : array { $ data = [ ] ; $ configurationObject = $ this -> configuration -> getConfigurationObjectForClass ( new ClassName ( get_class ( $ object ) ) ) ; $ identifier = $ configurationObject -> getIdentifier ( ) ; if ( $ identifier !== '' ) { $ data [ $ this -> configuration -> ge... | Create array from object |
3,696 | protected function checkNullForAttribute ( $ value , $ attribute ) : bool { if ( $ value === null ) { return true ; } if ( is_array ( $ value ) === true && $ value === [ ] ) { return true ; } if ( $ value instanceof \ Countable && count ( $ value ) === 0 ) { return true ; } return false ; } | Set attribute with value when value is not considered as a null value |
3,697 | public function extension ( $ idExtension ) : ExtensionInterface { if ( $ this -> hasExtension ( $ idExtension ) !== true ) { throw new \ OutOfBoundsException ( sprintf ( 'Extension "%s" not found.' , $ idExtension ) ) ; } return $ this -> extensions [ $ idExtension ] ; } | Get an extension by ID . |
3,698 | public function distanceFromPoint ( TrackPoint $ trackPoint ) : float { $ earthRadius = 6371000 ; $ latFrom = deg2rad ( $ this -> latitude ( ) ) ; $ lonFrom = deg2rad ( $ this -> longitude ( ) ) ; $ latTo = deg2rad ( $ trackPoint -> latitude ( ) ) ; $ lonTo = deg2rad ( $ trackPoint -> longitude ( ) ) ; $ latDelta = $ l... | Get the distance between this point and another point in meters . |
3,699 | public static function newFromTimeString ( $ timeString ) { try { $ dateTime = new DateTime ( $ timeString ) ; } catch ( \ Exception $ e ) { throw new InvalidArgumentException ( 'Time string must be valid, see DateTime for documentation' ) ; } return new self ( $ dateTime -> format ( 'G' ) , $ dateTime -> format ( 'i' ... | Creates new DailyDateRepetition from string readable by DateTime |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.