idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
47,300
|
function _createsCircularReference ( $ subject_to_embed , $ subject_stack ) { for ( $ i = count ( $ subject_stack ) - 1 ; $ i >= 0 ; -- $ i ) { if ( $ subject_stack [ $ i ] -> { '@id' } === $ subject_to_embed -> { '@id' } ) { return true ; } } return false ; }
|
Checks the current subject stack to see if embedding the given subject would cause a circular reference .
|
47,301
|
protected function _getFrameFlag ( $ frame , $ options , $ name ) { $ flag = "@$name" ; $ rval = ( property_exists ( $ frame , $ flag ) ? $ frame -> { $ flag } [ 0 ] : $ options [ $ name ] ) ; if ( $ name === 'embed' ) { if ( $ rval === true ) { $ rval = '@last' ; } else if ( $ rval === false ) { $ rval = '@never' ; } else if ( $ rval !== '@always' && $ rval !== '@never' && $ rval !== '@link' ) { $ rval = '@last' ; } } return $ rval ; }
|
Gets the frame flag value for the given flag name .
|
47,302
|
protected function _validateFrame ( $ frame ) { if ( ! is_array ( $ frame ) || count ( $ frame ) !== 1 || ! is_object ( $ frame [ 0 ] ) ) { throw new JsonLdException ( 'Invalid JSON-LD syntax; a JSON-LD frame must be a single object.' , 'jsonld.SyntaxError' , null , array ( 'frame' => $ frame ) ) ; } }
|
Validates a JSON - LD frame throwing an exception if the frame is invalid .
|
47,303
|
protected function _filterSubjects ( $ state , $ subjects , $ frame , $ flags ) { $ rval = new stdClass ( ) ; sort ( $ subjects ) ; foreach ( $ subjects as $ id ) { $ subject = $ state -> subjects -> { $ id } ; if ( $ this -> _filterSubject ( $ subject , $ frame , $ flags ) ) { $ rval -> { $ id } = $ subject ; } } return $ rval ; }
|
Returns a map of all of the subjects that match a parsed frame .
|
47,304
|
protected function _filterSubject ( $ subject , $ frame , $ flags ) { if ( property_exists ( $ frame , '@type' ) && ! ( count ( $ frame -> { '@type' } ) === 1 && is_object ( $ frame -> { '@type' } [ 0 ] ) ) ) { $ types = $ frame -> { '@type' } ; foreach ( $ types as $ type ) { if ( self :: hasValue ( $ subject , '@type' , $ type ) ) { return true ; } } return false ; } $ wildcard = true ; $ matches_some = false ; foreach ( $ frame as $ k => $ v ) { if ( self :: _isKeyword ( $ k ) ) { if ( $ k !== '@id' && $ k !== '@type' ) { continue ; } $ wildcard = false ; if ( $ k === '@id' && is_string ( $ v ) ) { if ( ! property_exists ( $ subject , $ k ) || $ subject -> { $ k } !== $ v ) { return false ; } $ matches_some = true ; continue ; } } $ wildcard = false ; if ( property_exists ( $ subject , $ k ) ) { if ( is_array ( $ v ) && count ( $ v ) === 0 ) { return false ; } $ matches_some = true ; continue ; } $ has_default = ( is_array ( $ v ) && count ( $ v ) === 1 && is_object ( $ v [ 0 ] ) && property_exists ( $ v [ 0 ] , '@default' ) ) ; if ( $ flags [ 'requireAll' ] && ! $ has_default ) { return false ; } } return $ wildcard || $ matches_some ; }
|
Returns true if the given subject matches the given frame .
|
47,305
|
protected function _removeEmbed ( $ state , $ id ) { $ embeds = $ state -> uniqueEmbeds ; $ embed = $ embeds -> { $ id } ; $ property = $ embed [ 'property' ] ; $ subject = ( object ) array ( '@id' => $ id ) ; if ( is_array ( $ embed -> parent ) ) { foreach ( $ embed -> parent as $ i => $ parent ) { if ( self :: compareValues ( $ parent , $ subject ) ) { $ embed -> parent [ $ i ] = $ subject ; break ; } } } else { $ use_array = is_array ( $ embed -> parent -> { $ property } ) ; self :: removeValue ( $ embed -> parent , $ property , $ subject , array ( 'propertyIsArray' => $ use_array ) ) ; self :: addValue ( $ embed -> parent , $ property , $ subject , array ( 'propertyIsArray' => $ use_array ) ) ; } $ removeDependents = function ( $ id ) { $ ids = array_keys ( ( array ) $ embeds ) ; foreach ( $ ids as $ next ) { if ( property_exists ( $ embeds , $ next ) && is_object ( $ embeds -> { $ next } -> parent ) && $ embeds -> { $ next } -> parent -> { '@id' } === $ id ) { unset ( $ embeds -> { $ next } ) ; $ removeDependents ( $ next ) ; } } } ; $ removeDependents ( $ id ) ; }
|
Removes an existing embed .
|
47,306
|
protected function _addFrameOutput ( $ parent , $ property , $ output ) { if ( is_object ( $ parent ) && ! ( $ parent instanceof ArrayObject ) ) { self :: addValue ( $ parent , $ property , $ output , array ( 'propertyIsArray' => true ) ) ; } else { $ parent [ ] = $ output ; } }
|
Adds framing output to the given parent .
|
47,307
|
protected static function _compareRDFTriples ( $ t1 , $ t2 ) { foreach ( array ( 'subject' , 'predicate' , 'object' ) as $ attr ) { if ( $ t1 -> { $ attr } -> type !== $ t2 -> { $ attr } -> type || $ t1 -> { $ attr } -> value !== $ t2 -> { $ attr } -> value ) { return false ; } } if ( property_exists ( $ t1 -> object , 'language' ) !== property_exists ( $ t1 -> object , 'language' ) ) { return false ; } if ( property_exists ( $ t1 -> object , 'language' ) && $ t1 -> object -> language !== $ t2 -> object -> language ) { return false ; } if ( property_exists ( $ t1 -> object , 'datatype' ) && $ t1 -> object -> datatype !== $ t2 -> object -> datatype ) { return false ; } return true ; }
|
Compares two RDF triples for equality .
|
47,308
|
protected function _hashQuads ( $ id , $ bnodes , $ namer ) { if ( property_exists ( $ bnodes -> { $ id } , 'hash' ) ) { return $ bnodes -> { $ id } -> hash ; } $ quads = $ bnodes -> { $ id } -> quads ; $ nquads = array ( ) ; foreach ( $ quads as $ quad ) { $ nquads [ ] = $ this -> toNQuad ( $ quad , property_exists ( $ quad , 'name' ) ? $ quad -> name -> value : null , $ id ) ; } sort ( $ nquads ) ; $ hash = $ bnodes -> { $ id } -> hash = sha1 ( implode ( $ nquads ) ) ; return $ hash ; }
|
Hashes all of the quads about a blank node .
|
47,309
|
protected function _selectTerm ( $ active_ctx , $ iri , $ value , $ containers , $ type_or_language , $ type_or_language_value ) { if ( $ type_or_language_value === null ) { $ type_or_language_value = '@null' ; } $ prefs = array ( ) ; if ( ( $ type_or_language_value === '@id' || $ type_or_language_value === '@reverse' ) && self :: _isSubjectReference ( $ value ) ) { if ( $ type_or_language_value === '@reverse' ) { $ prefs [ ] = '@reverse' ; } $ term = $ this -> _compactIri ( $ active_ctx , $ value -> { '@id' } , null , array ( 'vocab' => true ) ) ; if ( property_exists ( $ active_ctx -> mappings , $ term ) && $ active_ctx -> mappings -> { $ term } && $ active_ctx -> mappings -> { $ term } -> { '@id' } === $ value -> { '@id' } ) { array_push ( $ prefs , '@vocab' , '@id' ) ; } else { array_push ( $ prefs , '@id' , '@vocab' ) ; } } else { $ prefs [ ] = $ type_or_language_value ; } $ prefs [ ] = '@none' ; $ container_map = $ active_ctx -> inverse -> { $ iri } ; foreach ( $ containers as $ container ) { if ( ! property_exists ( $ container_map , $ container ) ) { continue ; } $ type_or_language_value_map = $ container_map -> { $ container } -> { $ type_or_language } ; foreach ( $ prefs as $ pref ) { if ( ! property_exists ( $ type_or_language_value_map , $ pref ) ) { continue ; } return $ type_or_language_value_map -> { $ pref } ; } } return null ; }
|
Picks the preferred compaction term from the given inverse context entry .
|
47,310
|
function _expandIri ( $ active_ctx , $ value , $ relative_to = array ( ) , $ local_ctx = null , $ defined = null ) { if ( $ value === null || self :: _isKeyword ( $ value ) ) { return $ value ; } if ( $ local_ctx !== null && property_exists ( $ local_ctx , $ value ) && ! self :: _hasKeyValue ( $ defined , $ value , true ) ) { $ this -> _createTermDefinition ( $ active_ctx , $ local_ctx , $ value , $ defined ) ; } if ( isset ( $ relative_to [ 'vocab' ] ) && $ relative_to [ 'vocab' ] ) { if ( property_exists ( $ active_ctx -> mappings , $ value ) ) { $ mapping = $ active_ctx -> mappings -> { $ value } ; if ( $ mapping === null ) { return null ; } return $ mapping -> { '@id' } ; } } $ colon = strpos ( $ value , ':' ) ; if ( $ colon !== false ) { $ prefix = substr ( $ value , 0 , $ colon ) ; $ suffix = substr ( $ value , $ colon + 1 ) ; if ( $ prefix === '_' || strpos ( $ suffix , '//' ) === 0 ) { return $ value ; } if ( $ local_ctx !== null && property_exists ( $ local_ctx , $ prefix ) ) { $ this -> _createTermDefinition ( $ active_ctx , $ local_ctx , $ prefix , $ defined ) ; } if ( property_exists ( $ active_ctx -> mappings , $ prefix ) ) { $ mapping = $ active_ctx -> mappings -> { $ prefix } ; if ( $ mapping ) { return $ mapping -> { '@id' } . $ suffix ; } } return $ value ; } if ( isset ( $ relative_to [ 'vocab' ] ) && $ relative_to [ 'vocab' ] && property_exists ( $ active_ctx , '@vocab' ) ) { return $ active_ctx -> { '@vocab' } . $ value ; } $ rval = $ value ; if ( isset ( $ relative_to [ 'base' ] ) && $ relative_to [ 'base' ] ) { $ rval = jsonld_prepend_base ( $ active_ctx -> { '@base' } , $ rval ) ; } return $ rval ; }
|
Expands a string to a full IRI . The string may be a term a prefix a relative IRI or an absolute IRI . The associated absolute IRI will be returned .
|
47,311
|
function _buildIriMap ( $ iri_map , $ key , $ idx ) { $ entries = $ iri_map [ $ key ] ; $ next = $ iri_map [ $ key ] = new ArrayObject ( ) ; foreach ( $ entries as $ entry ) { $ iri = $ entry -> iri ; if ( $ idx >= strlen ( $ iri ) ) { $ letter = '' ; } else { $ letter = $ iri [ $ idx ] ; } if ( ! isset ( $ next [ $ letter ] ) ) { $ next [ $ letter ] = new ArrayObject ( ) ; } $ next [ $ letter ] [ ] = $ entry ; } foreach ( $ next as $ key => $ value ) { if ( $ key === '' ) { continue ; } $ this -> _buildIriMap ( $ next , $ key , $ idx + 1 ) ; } }
|
Runs a recursive algorithm to build a lookup map for quickly finding potential CURIEs .
|
47,312
|
function _addPreferredTerm ( $ mapping , $ term , $ entry , $ type_or_language_value ) { if ( ! property_exists ( $ entry , $ type_or_language_value ) ) { $ entry -> { $ type_or_language_value } = $ term ; } }
|
Adds the term for the given entry if not already added .
|
47,313
|
protected function _cloneActiveContext ( $ active_ctx ) { $ child = new stdClass ( ) ; $ child -> { '@base' } = $ active_ctx -> { '@base' } ; $ child -> mappings = self :: copy ( $ active_ctx -> mappings ) ; $ child -> inverse = null ; if ( property_exists ( $ active_ctx , '@language' ) ) { $ child -> { '@language' } = $ active_ctx -> { '@language' } ; } if ( property_exists ( $ active_ctx , '@vocab' ) ) { $ child -> { '@vocab' } = $ active_ctx -> { '@vocab' } ; } return $ child ; }
|
Clones an active context creating a child active context .
|
47,314
|
protected static function _isSubject ( $ v ) { $ rval = false ; if ( is_object ( $ v ) && ! property_exists ( $ v , '@value' ) && ! property_exists ( $ v , '@set' ) && ! property_exists ( $ v , '@list' ) ) { $ count = count ( get_object_vars ( $ v ) ) ; $ rval = ( $ count > 1 || ! property_exists ( $ v , '@id' ) ) ; } return $ rval ; }
|
Returns true if the given value is a subject with properties .
|
47,315
|
protected static function _isBlankNode ( $ v ) { $ rval = false ; if ( is_object ( $ v ) ) { if ( property_exists ( $ v , '@id' ) ) { $ rval = ( strpos ( $ v -> { '@id' } , '_:' ) === 0 ) ; } else { $ rval = ( count ( get_object_vars ( $ v ) ) === 0 || ! ( property_exists ( $ v , '@value' ) || property_exists ( $ v , '@set' ) || property_exists ( $ v , '@list' ) ) ) ; } } return $ rval ; }
|
Returns true if the given value is a blank node .
|
47,316
|
protected static function _hasKeyValue ( $ target , $ key , $ value ) { return ( property_exists ( $ target , $ key ) && $ target -> { $ key } === $ value ) ; }
|
Returns true if the given target has the given key and its value equals is the given value .
|
47,317
|
protected static function _compareKeyValues ( $ o1 , $ o2 , $ key ) { if ( property_exists ( $ o1 , $ key ) ) { return property_exists ( $ o2 , $ key ) && $ o1 -> { $ key } === $ o2 -> { $ key } ; } return ! property_exists ( $ o2 , $ key ) ; }
|
Returns true if both of the given objects have the same value for the given key or if neither of the objects contain the given key .
|
47,318
|
protected static function _parse_json ( $ json ) { $ rval = json_decode ( $ json ) ; $ error = json_last_error ( ) ; if ( $ error === JSON_ERROR_NONE && $ rval === null ) { $ error = JSON_ERROR_SYNTAX ; } switch ( $ error ) { case JSON_ERROR_NONE : break ; case JSON_ERROR_DEPTH : throw new JsonLdException ( 'Could not parse JSON; the maximum stack depth has been exceeded.' , 'jsonld.ParseError' ) ; case JSON_ERROR_STATE_MISMATCH : throw new JsonLdException ( 'Could not parse JSON; invalid or malformed JSON.' , 'jsonld.ParseError' ) ; case JSON_ERROR_CTRL_CHAR : case JSON_ERROR_SYNTAX : throw new JsonLdException ( 'Could not parse JSON; syntax error, malformed JSON.' , 'jsonld.ParseError' ) ; case JSON_ERROR_UTF8 : throw new JsonLdException ( 'Could not parse JSON from URL; malformed UTF-8 characters.' , 'jsonld.ParseError' ) ; default : throw new JsonLdException ( 'Could not parse JSON from URL; unknown error.' , 'jsonld.ParseError' ) ; } return $ rval ; }
|
Parses JSON and sets an appropriate exception message on error .
|
47,319
|
public function getName ( $ old_name = null ) { if ( $ old_name && property_exists ( $ this -> existing , $ old_name ) ) { return $ this -> existing -> { $ old_name } ; } $ name = $ this -> prefix . $ this -> counter ; $ this -> counter += 1 ; if ( $ old_name !== null ) { $ this -> existing -> { $ old_name } = $ name ; $ this -> order [ ] = $ old_name ; } return $ name ; }
|
Gets the new name for the given old name where if no old name is given a new name will be generated .
|
47,320
|
public function get ( $ active_ctx , $ local_ctx ) { $ key1 = serialize ( $ active_ctx ) ; $ key2 = serialize ( $ local_ctx ) ; if ( property_exists ( $ this -> cache , $ key1 ) ) { $ level1 = $ this -> cache -> { $ key1 } ; if ( property_exists ( $ level1 , $ key2 ) ) { return $ level1 -> { $ key2 } ; } } return null ; }
|
Gets an active context from the cache based on the current active context and the new local context .
|
47,321
|
public function set ( $ active_ctx , $ local_ctx , $ result ) { if ( count ( $ this -> order ) === $ this -> size ) { $ entry = array_shift ( $ this -> order ) ; unset ( $ this -> cache -> { $ entry -> activeCtx } -> { $ entry -> localCtx } ) ; } $ key1 = serialize ( $ active_ctx ) ; $ key2 = serialize ( $ local_ctx ) ; $ this -> order [ ] = ( object ) array ( 'activeCtx' => $ key1 , 'localCtx' => $ key2 ) ; if ( ! property_exists ( $ this -> cache , $ key1 ) ) { $ this -> cache -> { $ key1 } = new stdClass ( ) ; } $ this -> cache -> { $ key1 } -> { $ key2 } = JsonLdProcessor :: copy ( $ result ) ; }
|
Sets an active context in the cache based on the previous active context and the just - processed local context .
|
47,322
|
public function getEmailHash ( ) { if ( $ this -> _emailHash !== null ) { return $ this -> _emailHash ; } elseif ( $ this -> email === null ) { throw new InvalidConfigException ( 'No email specified for Gravatar image Widget.' ) ; } return $ this -> _emailHash = md5 ( strtolower ( trim ( $ this -> email ) ) ) ; }
|
Generates email hash for gravatar url
|
47,323
|
public function extract ( array $ data ) { if ( ! array_key_exists ( 'class' , $ data ) ) { throw new \ RuntimeException ( 'Unable to extract class name from data' ) ; } if ( ! array_key_exists ( 'data' , $ data ) ) { throw new \ RuntimeException ( 'Unable to extract message body from data' ) ; } if ( ! is_array ( $ data [ 'data' ] ) ) { throw new \ RuntimeException ( 'Message body from data must be an array' ) ; } if ( ! class_exists ( $ data [ 'class' ] ) ) { throw new \ RuntimeException ( sprintf ( 'Class %s does\'nt exist' , $ data [ 'class' ] ) ) ; } if ( ! in_array ( MessageInterface :: class , class_implements ( $ data [ 'class' ] ) ) ) { throw new \ RuntimeException ( sprintf ( 'Class must implement %s' , MessageInterface :: class ) ) ; } $ message = new $ data [ 'class' ] ; if ( is_subclass_of ( $ data [ 'class' ] , MessageAwareInterface :: class ) ) { $ message -> setMessage ( $ this -> extract ( $ data [ 'data' ] ) ) ; unset ( $ data [ 'data' ] [ 'class' ] ) ; unset ( $ data [ 'data' ] [ 'data' ] ) ; } return $ this -> getHydrator ( ) -> hydrate ( $ message , $ data [ 'data' ] ) ; }
|
Extract a MessageInterface instance from data
|
47,324
|
public function buildEncrypted ( $ certificate ) { $ stream = new Stream ( 'php://temp' , 'wb+' ) ; $ content = base64_encode ( ( new Cryptography ( ) ) -> encrypt ( json_encode ( new MessageDecorator ( $ this -> getMessage ( ) ) ) , $ certificate ) ) ; $ stream -> write ( $ content ) ; return $ this -> getHttpMessage ( ) -> withAddedHeader ( 'Content-Type' , 'text/plain' ) -> withBody ( $ stream ) ; }
|
Build the encrypted response to send
|
47,325
|
public function build ( ) { $ stream = new Stream ( 'php://temp' , 'wb+' ) ; $ stream -> write ( json_encode ( new MessageDecorator ( $ this -> getMessage ( ) ) ) ) ; return $ this -> getHttpMessage ( ) -> withAddedHeader ( 'Content-Type' , 'application/json' ) -> withBody ( $ stream ) ; }
|
Build the response to send
|
47,326
|
public function createPrivateKey ( ) { $ rsa = new RSA ( ) ; $ rsa -> setPrivateKeyFormat ( RSA :: PRIVATE_FORMAT_PKCS1 ) ; return $ rsa -> createKey ( $ this -> getPrivateKeySize ( ) ) [ 'privatekey' ] ; }
|
Create a RSA private key
|
47,327
|
public function extract ( HttpMessageInterface $ httpMessage , $ privateKey ) { $ httpMessage -> getBody ( ) -> rewind ( ) ; $ message = $ httpMessage -> getBody ( ) -> getContents ( ) ; $ message = ( new Cryptography ( ) ) -> decrypt ( base64_decode ( $ message ) , $ privateKey ) ; return $ this -> getMessageExtractor ( ) -> extract ( \ json_decode ( $ message , true ) ) ; }
|
Extract a MessageInterface instance from a response
|
47,328
|
public function hydrate ( MessageInterface $ message , array $ data ) { foreach ( $ data as $ key => $ value ) { $ setter = 'set' . ucfirst ( $ key ) ; if ( ! method_exists ( $ message , $ setter ) ) { throw new \ RuntimeException ( sprintf ( 'Unable to found setter for "%s" data key' , $ key ) ) ; } $ message -> $ setter ( $ value ) ; } return $ message ; }
|
Hydrate a Message with data
|
47,329
|
public function addUserGroups ( UserGroup ... $ groups ) { foreach ( $ groups as $ group ) { $ this -> getUserGroups ( ) -> add ( $ group ) ; } return $ this ; }
|
Add user group
|
47,330
|
public function removeUserGroups ( UserGroup ... $ groups ) { foreach ( $ groups as $ group ) { $ this -> getUserGroups ( ) -> removeElement ( $ group ) ; } return $ this ; }
|
Remove user group
|
47,331
|
public function addDefaultRoles ( DefaultRole ... $ roles ) { foreach ( $ roles as $ role ) { $ this -> getDefaultRoles ( ) -> add ( $ role ) ; } return $ this ; }
|
Add default role .
|
47,332
|
public function removeDefaultRoles ( DefaultRole ... $ roles ) { foreach ( $ roles as $ role ) { $ this -> getDefaultRoles ( ) -> removeElement ( $ role ) ; } return $ this ; }
|
Remove default role .
|
47,333
|
public function encrypt ( $ contents , $ certificate ) { $ x509 = new X509 ( ) ; $ x509 -> loadX509 ( $ certificate ) ; $ rsa = new RSA ( ) ; $ rsa -> loadKey ( $ x509 -> getPublicKey ( ) ) ; $ rsa -> setSignatureMode ( RSA :: ENCRYPTION_PKCS1 ) ; return $ rsa -> encrypt ( $ contents ) ; }
|
Encrypt contents with the recipient s X . 509 certificate
|
47,334
|
public function decrypt ( $ encrypted , $ privateKey ) { $ rsa = new RSA ( ) ; $ rsa -> loadKey ( $ privateKey ) ; return $ rsa -> decrypt ( $ encrypted ) ; }
|
Decrypt encrypted contents with the recipient s private key
|
47,335
|
public function createTokenRequest ( User $ user , $ issuer ) { $ idAttribution = $ user -> getCurrentAttribution ( ) ? $ user -> getCurrentAttribution ( ) -> getId ( ) : null ; return ( new TokenRequest ( ) ) -> setUsername ( $ user -> getUserName ( ) ) -> setAttributionId ( $ idAttribution ) -> setIssuer ( $ issuer ) ; }
|
Create a request for a token with an User entity
|
47,336
|
public function signTokenRequest ( TokenRequest $ tokenRequest , $ privateKey ) { openssl_sign ( $ tokenRequest -> getIssuer ( ) . ':' . $ tokenRequest -> getUsername ( ) , $ signature , $ privateKey ) ; return $ tokenRequest -> setSignature ( base64_encode ( $ signature ) ) ; }
|
Sign a request token
|
47,337
|
public function verifySignature ( TokenRequest $ tokenRequest , $ certificate ) { $ result = openssl_verify ( $ tokenRequest -> getIssuer ( ) . ':' . $ tokenRequest -> getUsername ( ) , base64_decode ( $ tokenRequest -> getSignature ( ) ) , $ certificate ) ; return $ result === 1 ? true : false ; }
|
Verify the signature
|
47,338
|
public function validateRequestToken ( TokenRequest $ requestToken , $ certificate = null ) { if ( empty ( $ requestToken -> getIssuer ( ) ) || empty ( $ requestToken -> getSignature ( ) ) ) { return false ; } if ( ! is_null ( $ certificate ) ) { return $ this -> verifySignature ( $ requestToken , $ certificate ) ; } return true ; }
|
Validate a request token
|
47,339
|
public function createX509Certificate ( $ privateKey ) { $ rsa = new RSA ( ) ; $ rsa -> loadKey ( $ privateKey ) ; $ issuer = new X509 ( ) ; $ issuer -> setPrivateKey ( $ rsa ) ; $ issuer -> setDN ( $ this -> getDn ( ) ) ; $ csr = new X509 ( ) ; $ csr -> setPrivateKey ( $ rsa ) ; $ csr -> setDN ( $ issuer -> getDN ( ) ) ; $ csr = $ csr -> saveCSR ( $ csr -> signCSR ( ) ) ; $ subject = new X509 ( ) ; $ subject -> loadCSR ( $ csr ) ; $ x509 = new X509 ( ) ; $ x509 -> setEndDate ( $ this -> getCertificateValidity ( ) ) ; return $ x509 -> saveX509 ( $ x509 -> sign ( $ issuer , $ subject ) ) ; }
|
Create a X . 509 certificate
|
47,340
|
public function validateLogoUrl ( $ url ) { if ( empty ( $ url ) ) { return true ; } if ( ! is_string ( $ url ) ) { $ this -> addError ( 'url' , 'Url must be a string' ) ; return false ; } if ( mb_strlen ( $ url , 'UTF-8' ) > 255 ) { $ this -> addError ( 'url' , 'Url length has to be less or equal to 255' ) ; return false ; } if ( filter_var ( $ url , FILTER_VALIDATE_URL ) === false ) { $ this -> addError ( 'url' , 'Url must contain protocol and domain name' ) ; return false ; } return true ; }
|
Validate logo url
|
47,341
|
public function validateAllowProfileAssociation ( $ bool ) { if ( ! is_bool ( $ bool ) && ! is_numeric ( $ bool ) ) { $ this -> addError ( 'allow_profile_association' , 'Allow profile association must be a boolean or 0 or 1' ) ; return false ; } if ( 0 != ( integer ) $ bool && 1 != ( integer ) $ bool ) { $ this -> addError ( 'allow_profile_association' , 'Allow profile association must be a boolean or 0 or 1' ) ; return false ; } return true ; }
|
Validate allow profile association
|
47,342
|
public function validate ( EntityInterface $ entity ) { if ( ! $ entity instanceof EmailConfiguration ) { throw new Exception ( sprintf ( 'The Entity to validate must be an instance of %s' , EmailConfiguration :: class ) ) ; } $ this -> validateEmailSender ( $ entity -> getEmailSender ( ) ) ; $ this -> validateEmailSenderName ( $ entity -> getEmailSenderName ( ) ) ; $ this -> validateEmailSubjectPrefix ( $ entity -> getEmailSubjectPrefix ( ) ) ; $ this -> validateEmailBodySignature ( $ entity -> getEmailBodySignature ( ) ) ; $ errors = $ this -> getErrors ( ) ; return empty ( $ errors ) ; }
|
Validate an EmailConfiguration instance
|
47,343
|
public function validateEmailSender ( $ email ) { if ( mb_strlen ( $ email , 'UTF-8' ) > 255 ) { $ this -> addError ( EmailConfigurationTransformer :: EMAIL_SENDER , 'Sender email length has to be less or equal to 255' ) ; return false ; } if ( ! empty ( $ email ) ) { $ emailValidator = new EmailValidator ( ) ; if ( ! $ emailValidator -> isValid ( $ email , new RFCValidation ( ) ) ) { $ this -> addError ( EmailConfigurationTransformer :: EMAIL_SENDER , 'Sender email must be an email address' ) ; return false ; } } return true ; }
|
Validate sender email address
|
47,344
|
public function validateEmailSenderName ( $ name ) { if ( mb_strlen ( $ name , 'UTF-8' ) > 255 ) { $ this -> addError ( EmailConfigurationTransformer :: EMAIL_SENDER_NAME , 'Sender name length has to be less or equal to 255' ) ; return false ; } return true ; }
|
Validate sender name
|
47,345
|
public function validateEmailSubjectPrefix ( $ subjectPrefix ) { if ( mb_strlen ( $ subjectPrefix , 'UTF-8' ) > 255 ) { $ this -> addError ( EmailConfigurationTransformer :: EMAIL_SUBJECT_PREFIX , 'Subject prefix length has to be less or equal to 255' ) ; return false ; } return true ; }
|
Validate subject prefix
|
47,346
|
public function fetchLocalUsername ( ) { $ localUsername = null ; $ role = $ this -> getRole ( ) ; if ( $ role ) { $ roleParts = explode ( ':' , $ role -> getRole ( ) ) ; if ( count ( $ roleParts ) === 3 ) { $ localUsername = $ roleParts [ 2 ] ; } } return $ localUsername ; }
|
Get the Attribution Role localUsername
|
47,347
|
public function removeApplicationGroups ( ApplicationGroup ... $ groups ) { foreach ( $ groups as $ group ) { $ this -> getApplicationGroups ( ) -> removeElement ( $ group ) ; } return $ this ; }
|
Remove application groups
|
47,348
|
public function folderInfo ( $ folder = '/' ) { $ folder = $ this -> cleanFolder ( $ folder ) ; $ breadCrumbs = $ this -> breadcrumbs ( $ folder ) ; $ folderName = $ breadCrumbs -> pop ( ) ; $ subFolders = collect ( $ this -> disk -> directories ( $ folder ) ) -> reduce ( function ( $ subFolders , $ subFolder ) { if ( ! $ this -> isItemHidden ( $ subFolder ) ) { $ subFolders [ ] = $ this -> folderDetails ( $ subFolder ) ; } return $ subFolders ; } , collect ( [ ] ) ) ; $ files = collect ( $ this -> disk -> files ( $ folder ) ) -> reduce ( function ( $ files , $ path ) { if ( ! $ this -> isItemHidden ( $ path ) ) { $ files [ ] = $ this -> fileDetails ( $ path ) ; } return $ files ; } , collect ( [ ] ) ) ; $ itemsCount = $ subFolders -> count ( ) + $ files -> count ( ) ; return compact ( 'folder' , 'folderName' , 'breadCrumbs' , 'subFolders' , 'files' , 'itemsCount' ) ; }
|
Return files and directories within a folder .
|
47,349
|
protected function breadcrumbs ( $ folder ) { $ folder = trim ( $ folder , '/' ) ; $ folders = collect ( explode ( '/' , $ folder ) ) ; $ path = '' ; return $ folders -> reduce ( function ( $ crumbs , $ folder ) use ( & $ path ) { $ path .= '/' . $ folder ; $ crumbs [ $ path ] = $ folder ; return $ crumbs ; } , collect ( ) ) -> prepend ( $ this -> breadcrumbRootLabel , '/' ) ; }
|
Return breadcrumbs to current folder .
|
47,350
|
protected function folderDetails ( $ path ) { $ path = '/' . ltrim ( $ path , '/' ) ; return [ 'name' => basename ( $ path ) , 'mimeType' => 'folder' , 'fullPath' => $ path , 'modified' => $ this -> fileModified ( $ path ) , ] ; }
|
Return an array of folder details for a given folder .
|
47,351
|
protected function fileDetails ( $ path ) { $ path = '/' . ltrim ( $ path , '/' ) ; return [ 'name' => basename ( $ path ) , 'fullPath' => $ path , 'webPath' => $ this -> fileWebpath ( $ path ) , 'mimeType' => $ this -> fileMimeType ( $ path ) , 'size' => $ this -> fileSize ( $ path ) , 'modified' => $ this -> fileModified ( $ path ) , 'relativePath' => $ this -> fileRelativePath ( $ path ) , ] ; }
|
Return an array of file details for a given file .
|
47,352
|
public function fileModified ( $ path ) { try { return Carbon :: createFromTimestamp ( $ this -> disk -> lastModified ( $ path ) ) ; } catch ( \ Exception $ e ) { return Carbon :: now ( ) ; } }
|
Return the last modified time . If a timestamp can not be found fall back to today s date and time ...
|
47,353
|
public function allDirectories ( ) { $ directories = $ this -> disk -> allDirectories ( '/' ) ; return collect ( $ directories ) -> filter ( function ( $ directory ) { return ! ( starts_with ( $ directory , '.' ) ) ; } ) -> map ( function ( $ directory ) { return DIRECTORY_SEPARATOR . $ directory ; } ) -> reduce ( function ( $ allDirectories , $ directory ) { $ parts = explode ( '/' , $ directory ) ; $ name = str_repeat ( ' ' , ( count ( $ parts ) ) * 4 ) . basename ( $ directory ) ; $ allDirectories [ $ directory ] = $ name ; return $ allDirectories ; } , collect ( ) ) -> prepend ( $ this -> breadcrumbRootLabel , '/' ) ; }
|
Show all directories that the selected item can be moved to .
|
47,354
|
public function fileWebpath ( $ path ) { $ path = $ this -> disk -> url ( $ path ) ; $ path = preg_replace ( '/([^:])(\/{2,})/' , '$1/' , $ path ) ; return $ path ; }
|
Return the full web path to a file .
|
47,355
|
public function saveUploadedFiles ( UploadedFilesInterface $ files , $ path = '/' ) { return $ files -> getUploadedFiles ( ) -> reduce ( function ( $ uploaded , UploadedFile $ file ) use ( $ path ) { $ fileName = $ file -> getClientOriginalName ( ) ; if ( $ this -> disk -> exists ( $ path . $ fileName ) ) { $ this -> errors [ ] = 'File ' . $ path . $ fileName . ' already exists in this folder.' ; return $ uploaded ; } if ( ! $ file -> storeAs ( $ path , $ fileName , [ 'disk' => $ this -> diskName , 'visibility' => $ this -> access , ] ) ) { $ this -> errors [ ] = trans ( 'media-manager::messages.upload_error' , [ 'entity' => $ fileName ] ) ; return $ uploaded ; } $ uploaded ++ ; return $ uploaded ; } , 0 ) ; }
|
This method will take a collection of files that have been uploaded during a request and then save those files to the given path .
|
47,356
|
public function uploadFiles ( UploadFileRequest $ request ) { try { $ files = $ request -> file ( 'files' ) ; $ folder = $ request -> get ( 'folder' , '/' ) ; $ uploadedFiles = new UploadedFiles ( $ files ) ; $ response = $ this -> mediaManager -> saveUploadedFiles ( $ uploadedFiles , $ folder ) ; if ( $ response != 0 ) { $ response = trans ( 'media-manager::messages.upload_success' , [ 'entity' => $ response . ' New ' . str_plural ( 'File' , $ response ) ] ) ; } $ errors = $ this -> mediaManager -> errors ( ) ; if ( ! empty ( $ errors ) ) { return $ this -> errorResponse ( $ errors , $ response ) ; } return [ 'success' => $ response ] ; } catch ( \ Exception $ e ) { return $ this -> errorResponse ( [ $ e -> getMessage ( ) ] ) ; } }
|
Upload new file .
|
47,357
|
private function errorResponse ( $ error , $ notices = [ ] , $ errorCode = 400 ) { if ( is_array ( $ error ) ) { json_encode ( $ error ) ; } $ payload = [ 'error' => $ error ] ; if ( ! empty ( $ notices ) ) { $ payload [ 'notices' ] = $ notices ; } return \ Response :: json ( $ payload , $ errorCode ) ; }
|
Upload multiple files .
|
47,358
|
public static function get ( ) { $ middleware = config ( 'media-manager.routes.middleware' ) ; if ( ! empty ( $ middleware ) ) { Route :: group ( [ 'middleware' => $ middleware ] , function ( ) { self :: loadRoutes ( ) ; } ) ; return ; } self :: loadRoutes ( ) ; }
|
Returns the routes for the media manager wraps the routes with a route prefix or configured middleware where defined ...
|
47,359
|
private static function loadRoutes ( ) { Route :: group ( [ 'prefix' => config ( 'media-manager.routes.prefix' ) ] , function ( ) { Route :: get ( 'browser/index' , '\TalvBansal\MediaManager\Http\Controllers\MediaController@ls' ) ; Route :: post ( 'browser/file' , '\TalvBansal\MediaManager\Http\Controllers\MediaController@uploadFiles' ) ; Route :: delete ( 'browser/file' , '\TalvBansal\MediaManager\Http\Controllers\MediaController@deleteFile' ) ; Route :: post ( 'browser/folder' , '\TalvBansal\MediaManager\Http\Controllers\MediaController@createFolder' ) ; Route :: delete ( 'browser/folder' , '\TalvBansal\MediaManager\Http\Controllers\MediaController@deleteFolder' ) ; Route :: post ( 'browser/rename' , '\TalvBansal\MediaManager\Http\Controllers\MediaController@rename' ) ; Route :: get ( 'browser/directories' , '\TalvBansal\MediaManager\Http\Controllers\MediaController@allDirectories' ) ; Route :: post ( 'browser/move' , '\TalvBansal\MediaManager\Http\Controllers\MediaController@move' ) ; } ) ; }
|
Get all of the media manager routes .
|
47,360
|
protected function addVersion ( Builder $ builder ) { $ builder -> macro ( 'version' , function ( Builder $ builder , $ version ) { $ model = $ builder -> getModel ( ) ; $ this -> remove ( $ builder , $ builder -> getModel ( ) ) ; $ builder -> join ( $ model -> getVersionTable ( ) , function ( $ join ) use ( $ model , $ version ) { $ join -> on ( $ model -> getQualifiedKeyName ( ) , '=' , $ model -> getQualifiedVersionKeyName ( ) ) ; $ join -> where ( $ model -> getQualifiedVersionColumn ( ) , '=' , $ version ) ; } ) ; return $ builder ; } ) ; }
|
Add the version extension to the builder .
|
47,361
|
protected function addAllVersions ( Builder $ builder ) { $ builder -> macro ( 'allVersions' , function ( Builder $ builder ) { $ model = $ builder -> getModel ( ) ; $ this -> remove ( $ builder , $ builder -> getModel ( ) ) ; $ builder -> join ( $ model -> getVersionTable ( ) , function ( $ join ) use ( $ model ) { $ join -> on ( $ model -> getQualifiedKeyName ( ) , '=' , $ model -> getQualifiedVersionKeyName ( ) ) ; } ) ; return $ builder ; } ) ; }
|
Add the allVersions extension to the builder .
|
47,362
|
protected function addMoment ( Builder $ builder ) { $ builder -> macro ( 'moment' , function ( Builder $ builder , Carbon $ moment ) { $ model = $ builder -> getModel ( ) ; $ this -> remove ( $ builder , $ builder -> getModel ( ) ) ; $ builder -> join ( $ model -> getVersionTable ( ) , function ( $ join ) use ( $ model , $ moment ) { $ join -> on ( $ model -> getQualifiedKeyName ( ) , '=' , $ model -> getQualifiedVersionKeyName ( ) ) ; $ join -> where ( 'updated_at' , '<=' , $ moment ) -> orderBy ( 'updated_at' , 'desc' ) -> limit ( 1 ) ; } ) -> orderBy ( 'updated_at' , 'desc' ) -> limit ( 1 ) ; return $ builder ; } ) ; }
|
Add the moment extension to the builder .
|
47,363
|
protected function hasVersionJoin ( Builder $ builder , string $ table ) { return collect ( $ builder -> getQuery ( ) -> joins ) -> pluck ( 'table' ) -> contains ( $ table ) ; }
|
Determine if the given builder contains a join with the given table
|
47,364
|
public function getQualifiedDeletedAtColumn ( ) { $ deletedAt = $ this -> getDeletedAtColumn ( ) ; if ( isset ( $ this -> versioned ) && in_array ( $ deletedAt , $ this -> versioned ) ) { return $ this -> getVersionTable ( ) . '.' . $ deletedAt ; } return $ this -> getTable ( ) . '.' . $ deletedAt ; }
|
Get the fully qualified deleted at column .
|
47,365
|
public function forceDelete ( ) { $ affectedRecords = $ this -> getAffectedRecords ( ) -> toArray ( ) ; $ ids = array_map ( function ( $ record ) { return $ record -> { $ this -> model -> getKeyName ( ) } ; } , $ affectedRecords ) ; if ( ! $ this -> query -> delete ( ) ) { return false ; } $ db = $ this -> model -> getConnection ( ) ; return $ db -> table ( $ this -> model -> getVersionTable ( ) ) -> whereIn ( $ this -> model -> getVersionKeyName ( ) , $ ids ) -> delete ( ) ; }
|
Run the default delete function on the builder .
|
47,366
|
protected function getAffectedRecords ( ) { if ( $ this -> model -> getKey ( ) ) { $ records = [ $ this -> model ] ; } else { $ records = $ this -> query -> get ( ) ; } return $ records ; }
|
Get affected records .
|
47,367
|
protected function isVersionedKey ( $ key , array $ versionedKeys ) { $ segments = explode ( "." , $ key ) ; if ( count ( $ segments ) > 2 ) { throw new Exception ( "Key '" . $ key . "' has too many fractions." ) ; } if ( count ( $ segments ) == 1 && in_array ( $ segments [ 0 ] , $ versionedKeys ) ) { return $ segments [ 0 ] ; } if ( count ( $ segments ) == 2 && $ segments [ 0 ] == $ this -> model -> getVersionTable ( ) && in_array ( $ segments [ 1 ] , $ versionedKeys ) ) { return $ segments [ 1 ] ; } return null ; }
|
Check if key is in versioned keys .
|
47,368
|
public function install ( Environment $ twig ) : Environment { $ twig = clone $ twig ; $ extension = new Extension ( $ this -> pipeline ) ; $ twig -> addExtension ( $ extension ) ; $ compiler = new PatchingCompiler ( $ twig ) ; $ twig -> setCompiler ( $ compiler ) ; return $ twig ; }
|
Returns a Twig instance with Shoot installed . Does not modify the original instance .
|
47,369
|
public function for ( Source $ source ) : string { if ( isset ( $ this -> presentationModels [ $ source ] ) ) { return ( string ) $ this -> presentationModels [ $ source ] ; } return PresentationModel :: class ; }
|
Returns the presentation model for the given view .
|
47,370
|
private function hasData ( PresentationModel $ presentationModel ) : bool { foreach ( $ presentationModel -> getVariables ( ) as $ value ) { if ( ! empty ( $ value ) ) { return true ; } } return false ; }
|
Returns whether the presentation model already holds data .
|
47,371
|
public function contains ( $ element , bool $ strict = true ) : bool { return \ in_array ( $ element , $ this -> data , $ strict ) ; }
|
Returns true if this collection contains the specified element .
|
47,372
|
public function remove ( $ element ) : bool { if ( ( $ position = \ array_search ( $ element , $ this -> data , true ) ) !== false ) { unset ( $ this -> data [ $ position ] ) ; return true ; } return false ; }
|
Removes a single instance of the specified element from this collection if it is present .
|
47,373
|
public function first ( ) { if ( empty ( $ this -> data ) ) { throw new OutOfBoundsException ( 'Can\'t determine first item. Collection is empty' ) ; } \ reset ( $ this -> data ) ; return \ current ( $ this -> data ) ; }
|
Returns the first item of the collection .
|
47,374
|
public function last ( ) { if ( empty ( $ this -> data ) ) { throw new OutOfBoundsException ( 'Can\'t determine last item. Collection is empty' ) ; } $ item = \ end ( $ this -> data ) ; \ reset ( $ this -> data ) ; return $ item ; }
|
Returns the last item of the collection .
|
47,375
|
public function sort ( string $ propertyOrMethod , string $ order = self :: SORT_ASC ) : CollectionInterface { if ( ! \ in_array ( $ order , [ self :: SORT_ASC , self :: SORT_DESC ] , true ) ) { throw new InvalidSortOrderException ( 'Invalid sort order given: ' . $ order ) ; } $ collection = clone $ this ; \ usort ( $ collection -> data , function ( $ a , $ b ) use ( $ propertyOrMethod , $ order ) { $ aValue = $ this -> extractValue ( $ a , $ propertyOrMethod ) ; $ bValue = $ this -> extractValue ( $ b , $ propertyOrMethod ) ; return ( $ aValue <=> $ bValue ) * ( $ order === self :: SORT_DESC ? - 1 : 1 ) ; } ) ; return $ collection ; }
|
Returns a sorted collection .
|
47,376
|
public function filter ( callable $ callback ) : CollectionInterface { $ collection = clone $ this ; $ collection -> data = \ array_merge ( [ ] , \ array_filter ( $ collection -> data , $ callback ) ) ; return $ collection ; }
|
Returns a filtered collection .
|
47,377
|
public function map ( callable $ callback ) : CollectionInterface { $ collection = clone $ this ; \ array_map ( $ callback , $ collection -> data ) ; return $ collection ; }
|
Applies a callback to each item of the collection .
|
47,378
|
public function diff ( CollectionInterface $ other ) : CollectionInterface { if ( ! $ other instanceof static ) { throw new CollectionMismatchException ( 'Collection must be of type ' . static :: class ) ; } $ comparator = function ( $ a , $ b ) { return $ a === $ b ? 0 : - 1 ; } ; $ diffAtoB = \ array_udiff ( $ this -> data , $ other -> data , $ comparator ) ; $ diffBtoA = \ array_udiff ( $ other -> data , $ this -> data , $ comparator ) ; return new static ( \ array_merge ( $ diffAtoB , $ diffBtoA ) ) ; }
|
Create a new collection with divergent items between current and given collection .
|
47,379
|
public function intersect ( CollectionInterface $ other ) : CollectionInterface { if ( ! $ other instanceof static ) { throw new CollectionMismatchException ( 'Collection must be of type ' . static :: class ) ; } $ intersect = \ array_uintersect ( $ this -> data , $ other -> data , function ( $ a , $ b ) { return $ a === $ b ? 0 : - 1 ; } ) ; return new static ( $ intersect ) ; }
|
Create a new collection with intersecting item between current and given collection .
|
47,380
|
public function putIfAbsent ( $ key , $ value ) { $ currentValue = $ this -> get ( $ key ) ; if ( $ currentValue === null ) { $ this [ $ key ] = $ value ; } return $ currentValue ; }
|
Associates the specified value with the specified key in this map only if it is not already set .
|
47,381
|
public function removeIf ( $ key , $ value ) : bool { if ( $ this -> get ( $ key ) === $ value ) { unset ( $ this [ $ key ] ) ; return true ; } return false ; }
|
Removes the entry for the specified key only if it is currently mapped to the specified value .
|
47,382
|
public function replace ( $ key , $ value ) { $ currentValue = $ this -> get ( $ key ) ; if ( $ this -> containsKey ( $ key ) ) { $ this [ $ key ] = $ value ; } return $ currentValue ; }
|
Replaces the entry for the specified key only if it is currently mapped to some value .
|
47,383
|
public function replaceIf ( $ key , $ oldValue , $ newValue ) : bool { if ( $ this -> get ( $ key ) === $ oldValue ) { $ this [ $ key ] = $ newValue ; return true ; } return false ; }
|
Replaces the entry for the specified key only if currently mapped to the specified value .
|
47,384
|
protected function checkType ( string $ type , $ value ) : bool { switch ( $ type ) { case 'array' : return \ is_array ( $ value ) ; case 'bool' : case 'boolean' : return \ is_bool ( $ value ) ; case 'callable' : return \ is_callable ( $ value ) ; case 'float' : case 'double' : return \ is_float ( $ value ) ; case 'int' : case 'integer' : return \ is_int ( $ value ) ; case 'null' : return $ value === null ; case 'numeric' : return \ is_numeric ( $ value ) ; case 'object' : return \ is_object ( $ value ) ; case 'resource' : return \ is_resource ( $ value ) ; case 'scalar' : return \ is_scalar ( $ value ) ; case 'string' : return \ is_string ( $ value ) ; case 'mixed' : return true ; default : return ( $ value instanceof $ type ) ; } }
|
Returns true if value is of the specified type .
|
47,385
|
public function add ( $ element ) : bool { if ( $ this -> contains ( $ element ) ) { return false ; } return parent :: add ( $ element ) ; }
|
Adds the specified element to this set if it is not already present .
|
47,386
|
public function offsetSet ( $ offset , $ value ) : void { if ( $ this -> contains ( $ value ) ) { return ; } parent :: offsetSet ( $ offset , $ value ) ; }
|
Sets the given value to the given offset in this set if it is not already present .
|
47,387
|
public function offsetSet ( $ offset , $ value ) : void { if ( $ this -> checkType ( $ this -> getType ( ) , $ value ) === false ) { throw new InvalidArgumentException ( 'Value must be of type ' . $ this -> getType ( ) . '; value is ' . $ this -> toolValueToString ( $ value ) ) ; } $ this -> tail ++ ; $ this -> data [ $ this -> tail ] = $ value ; }
|
Sets the given value to the given offset in the queue .
|
47,388
|
public function addFirst ( $ element ) : bool { if ( $ this -> checkType ( $ this -> getType ( ) , $ element ) === false ) { throw new InvalidArgumentException ( 'Value must be of type ' . $ this -> getType ( ) . '; value is ' . $ this -> toolValueToString ( $ element ) ) ; } $ this -> index -- ; $ this -> data [ $ this -> index ] = $ element ; return true ; }
|
Ensures that the specified element is inserted at the front of this queue .
|
47,389
|
public function removeLast ( ) { if ( $ this -> count ( ) === 0 ) { throw new NoSuchElementException ( 'Can\'t return element from Queue. Queue is empty.' ) ; } $ tail = $ this [ $ this -> tail ] ; unset ( $ this [ $ this -> tail ] ) ; $ this -> tail -- ; return $ tail ; }
|
Retrieves and removes the tail of this queue .
|
47,390
|
public function pollLast ( ) { if ( $ this -> count ( ) === 0 ) { return null ; } $ tail = $ this [ $ this -> tail ] ; unset ( $ this [ $ this -> tail ] ) ; $ this -> tail -- ; return $ tail ; }
|
Retrieves and removes the tail of this queue or returns null if this queue is empty .
|
47,391
|
protected function filterNamedParameters ( array $ namedParameters ) : array { $ names = [ ] ; $ types = [ ] ; foreach ( $ namedParameters as $ key => $ value ) { if ( \ is_int ( $ key ) ) { $ names [ ] = ( string ) $ value ; $ types [ ] = 'mixed' ; } else { $ names [ ] = $ key ; $ types [ ] = ( string ) $ value ; } } return \ array_combine ( $ names , $ types ) ? : [ ] ; }
|
Given an array of named parameters constructs a proper mapping of named parameters to types .
|
47,392
|
public function poll ( ) { if ( $ this -> count ( ) === 0 ) { return null ; } $ head = $ this [ $ this -> index ] ; unset ( $ this [ $ this -> index ] ) ; $ this -> index ++ ; return $ head ; }
|
Retrieves and removes the head of this queue or returns null if this queue is empty .
|
47,393
|
public function remove ( ) { if ( $ this -> count ( ) === 0 ) { throw new NoSuchElementException ( 'Can\'t return element from Queue. Queue is empty.' ) ; } $ head = $ this [ $ this -> index ] ; unset ( $ this [ $ this -> index ] ) ; $ this -> index ++ ; return $ head ; }
|
Retrieves and removes the head of this queue .
|
47,394
|
public function vn ( $ vn = null ) { if ( $ vn !== null ) { $ this -> vn = strtoupper ( $ this -> escape ( $ vn ) ) ; return $ this ; } return $ this -> vn ; }
|
Gets or sets the verification number
|
47,395
|
public function number ( $ number = null ) { if ( $ number !== null ) { $ this -> number = $ this -> escape ( $ number ) ; return $ this ; } return $ this -> number ; }
|
Get or sets the RUT Number
|
47,396
|
public function minChars ( $ minChars = null ) { if ( $ minChars !== null ) { $ this -> minChars = $ minChars ; return $ this ; } return $ this -> minChars ; }
|
Get or sets the minimum amount of characters a RUT can have to ve valid
|
47,397
|
public function scape_chars ( array $ chars = null ) { if ( $ chars !== null ) { $ this -> escapeChars = $ chars ; return $ this ; } return $ this -> escapeChars ; }
|
Get or sets the scape chars
|
47,398
|
public function vnSeparator ( array $ vnSeparator = null ) { if ( $ vnSeparator !== null ) { $ this -> vnSeparator = $ vnSeparator ; return $ this ; } return $ this -> vnSeparator ; }
|
Get or sets the verification number separator
|
47,399
|
public static function split ( $ rut , $ vn = null ) { if ( ! is_null ( $ vn ) ) { return [ $ rut , $ vn ] ; } $ vn = ( substr ( $ rut , - 1 ) ) ; $ rut = substr ( $ rut , 0 , - 1 ) ; return [ $ rut , $ vn ] ; }
|
Splits the rut into rut and verification number .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.