idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
36,200
public function undelete ( ) : void { $ this -> clearHeaders ( ) ; if ( ! \ imap_undelete ( $ this -> resource -> getStream ( ) , $ this -> getNumber ( ) , \ FT_UID ) ) { throw new MessageUndeleteException ( \ sprintf ( 'Message "%s" cannot be undeleted' , $ this -> getNumber ( ) ) ) ; } }
Undelete message .
36,201
public function setFlag ( string $ flag ) : bool { $ result = \ imap_setflag_full ( $ this -> resource -> getStream ( ) , ( string ) $ this -> getNumber ( ) , $ flag , \ ST_UID ) ; $ this -> clearHeaders ( ) ; return $ result ; }
Set Flag Message .
36,202
public function clearFlag ( string $ flag ) : bool { $ result = \ imap_clearflag_full ( $ this -> resource -> getStream ( ) , ( string ) $ this -> getNumber ( ) , $ flag , \ ST_UID ) ; $ this -> clearHeaders ( ) ; return $ result ; }
Clear Flag Message .
36,203
public function getSize ( ) { $ size = $ this -> getParameters ( ) -> get ( 'size' ) ; if ( \ is_numeric ( $ size ) ) { $ size = ( int ) $ size ; } return $ size ; }
Get attachment file size .
36,204
public function getEmbeddedMessage ( ) : EmbeddedMessageInterface { if ( ! $ this -> isEmbeddedMessage ( ) ) { throw new NotEmbeddedMessageException ( \ sprintf ( 'Attachment "%s" in message "%s" is not embedded message' , $ this -> getPartNumber ( ) , $ this -> getNumber ( ) ) ) ; } return new EmbeddedMessage ( $ this...
Return embedded message .
36,205
public function toString ( ) : string { $ conditions = \ array_map ( static function ( ConditionInterface $ condition ) { return $ condition -> toString ( ) ; } , $ this -> conditions ) ; return \ sprintf ( '( %s )' , \ implode ( ' OR ' , $ conditions ) ) ; }
Returns the keyword that the condition represents .
36,206
public function getStream ( ) { if ( false === \ is_resource ( $ this -> resource ) || 'imap' !== \ get_resource_type ( $ this -> resource ) ) { throw new InvalidResourceException ( 'Supplied resource is not a valid imap resource' ) ; } $ this -> initMailbox ( ) ; return $ this -> resource ; }
Get IMAP resource stream .
36,207
private function initMailbox ( ) : void { if ( null === $ this -> mailbox || self :: isMailboxOpen ( $ this -> mailbox , $ this -> resource ) ) { return ; } \ imap_reopen ( $ this -> resource , $ this -> mailbox -> getFullEncodedName ( ) ) ; if ( self :: isMailboxOpen ( $ this -> mailbox , $ this -> resource ) ) { retu...
If connection is not currently in this mailbox switch it to this mailbox .
36,208
private static function isMailboxOpen ( MailboxInterface $ mailbox , $ resource ) : bool { $ currentMailboxName = $ mailbox -> getFullEncodedName ( ) ; if ( $ currentMailboxName === self :: $ lastMailboxUsedCache ) { return true ; } self :: $ lastMailboxUsedCache = null ; $ check = \ imap_check ( $ resource ) ; $ retur...
Check whether the current mailbox is open .
36,209
final public function getContent ( ) : string { if ( null === $ this -> content ) { $ this -> content = $ this -> doGetContent ( $ this -> getContentPartNumber ( ) ) ; } return $ this -> content ; }
Get raw part content .
36,210
final public function getDecodedContent ( ) : string { if ( null === $ this -> decodedContent ) { if ( self :: ENCODING_UNKNOWN === $ this -> getEncoding ( ) ) { throw new UnexpectedEncodingException ( 'Cannot decode a content with an uknown encoding' ) ; } $ content = $ this -> getContent ( ) ; if ( self :: ENCODING_B...
Get decoded part content .
36,211
final protected function doGetContent ( string $ partNumber ) : string { $ return = \ imap_fetchbody ( $ this -> resource -> getStream ( ) , $ this -> getNumber ( ) , $ partNumber , \ FT_UID | \ FT_PEEK ) ; if ( false === $ return ) { throw new ImapFetchbodyException ( 'imap_fetchbody failed' ) ; } return $ return ; }
Get raw message content .
36,212
private function lazyParseStructure ( ) : void { if ( true === $ this -> structureParsed ) { return ; } $ this -> structureParsed = true ; $ this -> lazyLoadStructure ( ) ; $ this -> type = self :: $ typesMap [ $ this -> structure -> type ] ?? self :: TYPE_UNKNOWN ; $ this -> encoding = self :: $ encodingsMap [ $ this ...
Parse part structure .
36,213
private static function isAttachment ( \ stdClass $ part ) : bool { if ( isset ( self :: $ typesMap [ $ part -> type ] ) && self :: TYPE_MULTIPART === self :: $ typesMap [ $ part -> type ] ) { return false ; } if ( $ part -> ifdisposition ) { if ( 'attachment' === \ strtolower ( $ part -> disposition ) ) { return true ...
Check if the given part is an attachment .
36,214
public function hasMailbox ( string $ name ) : bool { $ this -> initMailboxNames ( ) ; return isset ( $ this -> mailboxNames [ $ name ] ) ; }
Check that a mailbox with the given name exists .
36,215
public function getMailbox ( string $ name ) : MailboxInterface { if ( false === $ this -> hasMailbox ( $ name ) ) { throw new MailboxDoesNotExistException ( \ sprintf ( 'Mailbox name "%s" does not exist' , $ name ) ) ; } return new Mailbox ( $ this -> resource , $ name , $ this -> mailboxNames [ $ name ] ) ; }
Get a mailbox by its name .
36,216
private function initMailboxNames ( ) : void { if ( null !== $ this -> mailboxNames ) { return ; } $ this -> mailboxNames = [ ] ; $ mailboxesInfo = \ imap_getmailboxes ( $ this -> resource -> getStream ( ) , $ this -> server , '*' ) ; if ( ! \ is_array ( $ mailboxesInfo ) ) { throw new ImapGetmailboxesException ( 'imap...
Get mailbox names .
36,217
protected function prepareWritableDirectories ( $ appDirectory , OutputInterface $ output ) { $ filesystem = new Filesystem ; try { $ filesystem -> chmod ( $ appDirectory . DIRECTORY_SEPARATOR . 'bootstrap/cache' , 0755 , 0000 , true ) ; $ filesystem -> chmod ( $ appDirectory . DIRECTORY_SEPARATOR . 'storage' , 0755 , ...
Make sure the storage and bootstrap cache directories are writable .
36,218
public function getNativeName ( $ languageCode = null ) : ? string { $ languageCode = $ languageCode ? mb_strtolower ( $ languageCode ) : null ; return $ this -> get ( "name.native.{$languageCode}.common" ) ? : ( current ( $ this -> get ( 'name.native' , [ ] ) ) [ 'common' ] ? : $ this -> get ( 'native_name' ) ) ; }
Get the given native name or fallback to first native name .
36,219
public function getNativeOfficialName ( $ languageCode = null ) : ? string { $ languageCode = $ languageCode ? mb_strtolower ( $ languageCode ) : null ; return $ this -> get ( "name.native.{$languageCode}.official" ) ? : ( current ( $ this -> get ( 'name.native' , [ ] ) ) [ 'official' ] ? : $ this -> get ( 'native_offi...
Get the given native official name or fallback to first native official name .
36,220
public function getCurrency ( $ currency = null ) : ? array { $ currency = $ currency ? mb_strtoupper ( $ currency ) : null ; return $ this -> get ( "currency.{$currency}" ) ? : ( current ( $ this -> get ( 'currency' , [ ] ) ) ? : null ) ; }
Get the given currency or fallback to first currency .
36,221
public function getLanguage ( $ languageCode = null ) : ? string { $ languageCode = $ languageCode ? mb_strtoupper ( $ languageCode ) : null ; return $ this -> get ( "languages.{$languageCode}" ) ? : ( current ( $ this -> get ( 'languages' , [ ] ) ) ? : null ) ; }
Get the given language or fallback to first language .
36,222
public function getGeoJson ( ) : ? string { if ( ! ( $ code = $ this -> getIsoAlpha2 ( ) ) ) { return null ; } return file_exists ( $ file = __DIR__ . '/../resources/geodata/' . mb_strtolower ( $ code ) . '.json' ) ? file_get_contents ( $ file ) : null ; }
Get the geographic data structure .
36,223
public static function country ( $ code , $ hydrate = true ) { $ code = mb_strtolower ( $ code ) ; if ( ! isset ( static :: $ countries [ $ code ] ) ) { static :: $ countries [ $ code ] = json_decode ( static :: getFile ( __DIR__ . '/../resources/data/' . $ code . '.json' ) , true ) ; } return $ hydrate ? new Country (...
Get the country by it s ISO 3166 - 1 alpha - 2 .
36,224
public static function countries ( $ longlist = false , $ hydrate = false ) { $ list = $ longlist ? 'longlist' : 'shortlist' ; if ( ! isset ( static :: $ countries [ $ list ] ) ) { static :: $ countries [ $ list ] = json_decode ( static :: getFile ( __DIR__ . '/../resources/data/' . $ list . '.json' ) , true ) ; } retu...
Get all countries short - listed .
36,225
public function make ( array $ config ) : Pusher { $ config = $ this -> getConfig ( $ config ) ; return $ this -> getClient ( $ config ) ; }
Make a new Pusher client .
36,226
protected function getClient ( array $ auth ) : Pusher { return new Pusher ( $ auth [ 'auth_key' ] , $ auth [ 'secret' ] , $ auth [ 'app_id' ] , $ auth [ 'options' ] , $ auth [ 'host' ] , $ auth [ 'port' ] , $ auth [ 'timeout' ] ) ; }
Get the pusher client .
36,227
public function make ( array $ data , array $ rules ) { $ sanitizer = new Sanitizer ( $ data , $ rules , $ this -> customFilters ) ; return $ sanitizer ; }
Create a new Sanitizer instance
36,228
public function apply ( $ value , $ options = [ ] ) { if ( ! $ value ) { return $ value ; } if ( sizeof ( $ options ) != 2 ) { throw new InvalidArgumentException ( 'The Sanitizer Format Date filter requires both the current date format as well as the target format.' ) ; } $ currentFormat = trim ( $ options [ 0 ] ) ; $ ...
Lowercase the given string .
36,229
public function addCustomFilters ( ) { foreach ( $ this -> customFilters ( ) as $ name => $ filter ) { app ( 'sanitizer' ) -> extend ( $ name , $ filter ) ; } }
Add custom fields to the Sanitizer
36,230
protected function applyFilter ( $ name , $ value , $ options = [ ] ) { if ( ! isset ( $ this -> filters [ $ name ] ) ) { throw new InvalidArgumentException ( "No filter found by the name of $name" ) ; } $ filter = $ this -> filters [ $ name ] ; if ( $ filter instanceof Closure ) { return call_user_func_array ( $ filte...
Apply the given filter by its name
36,231
public function sanitize ( ) { $ sanitized = $ this -> data ; foreach ( $ this -> rules as $ attr => $ rules ) { if ( Arr :: has ( $ this -> data , $ attr ) ) { $ value = Arr :: get ( $ this -> data , $ attr ) ; foreach ( $ rules as $ rule ) { $ value = $ this -> applyFilter ( $ rule [ 'name' ] , $ value , $ rule [ 'op...
Sanitize the given data
36,232
public function apply ( $ value , $ options = [ ] ) { $ type = isset ( $ options [ 0 ] ) ? $ options [ 0 ] : null ; switch ( $ type ) { case 'int' : case 'integer' : return ( int ) $ value ; case 'real' : case 'float' : case 'double' : return ( float ) $ value ; case 'string' : return ( string ) $ value ; case 'bool' :...
Capitalize the given string .
36,233
public function addRequirement ( $ fulfilled , $ testMessage , $ helpHtml , $ helpText = null ) { $ this -> add ( new Requirement ( $ fulfilled , $ testMessage , $ helpHtml , $ helpText , false ) ) ; }
Adds a mandatory requirement .
36,234
public function addRecommendation ( $ fulfilled , $ testMessage , $ helpHtml , $ helpText = null ) { $ this -> add ( new Requirement ( $ fulfilled , $ testMessage , $ helpHtml , $ helpText , true ) ) ; }
Adds an optional recommendation .
36,235
public function addPhpIniRequirement ( $ cfgName , $ evaluation , $ approveCfgAbsence = false , $ testMessage = null , $ helpHtml = null , $ helpText = null ) { $ this -> add ( new PhpIniRequirement ( $ cfgName , $ evaluation , $ approveCfgAbsence , $ testMessage , $ helpHtml , $ helpText , false ) ) ; }
Adds a mandatory requirement in form of a php . ini configuration .
36,236
public function addPhpIniRecommendation ( $ cfgName , $ evaluation , $ approveCfgAbsence = false , $ testMessage = null , $ helpHtml = null , $ helpText = null ) { $ this -> add ( new PhpIniRequirement ( $ cfgName , $ evaluation , $ approveCfgAbsence , $ testMessage , $ helpHtml , $ helpText , true ) ) ; }
Adds an optional recommendation in form of a php . ini configuration .
36,237
public function getFailedRecommendations ( ) { $ array = array ( ) ; foreach ( $ this -> requirements as $ req ) { if ( ! $ req -> isFulfilled ( ) && $ req -> isOptional ( ) ) { $ array [ ] = $ req ; } } return $ array ; }
Returns the recommendations that were not met .
36,238
public function hasPhpIniConfigIssue ( ) { foreach ( $ this -> requirements as $ req ) { if ( ! $ req -> isFulfilled ( ) && $ req instanceof PhpIniRequirement ) { return true ; } } return false ; }
Returns whether a php . ini configuration is not correct .
36,239
protected function getPhpRequiredVersion ( ) { if ( ! file_exists ( $ path = __DIR__ . '/../composer.lock' ) ) { return false ; } $ composerLock = json_decode ( file_get_contents ( $ path ) , true ) ; foreach ( $ composerLock [ 'packages' ] as $ package ) { $ name = $ package [ 'name' ] ; if ( 'symfony/symfony' !== $ n...
Defines PHP required version from Symfony version .
36,240
public function link ( $ entity , $ attribute ) { $ this -> entity = $ entity ; $ this -> attribute = $ attribute ; return $ this ; }
Link the entity and attribute to this value collection .
36,241
public function add ( $ values ) { if ( ! is_array ( $ values ) && ! $ values instanceof BaseCollection ) { $ values = func_get_args ( ) ; } foreach ( $ values as $ value ) { $ this -> push ( $ this -> buildValue ( $ value ) ) ; } return $ this ; }
Add new values to the value collection .
36,242
public function replace ( $ values ) { if ( ! is_array ( $ values ) && ! $ values instanceof BaseCollection ) { $ values = func_get_args ( ) ; } $ this -> trashCurrentItems ( ) ; $ this -> items = $ this -> buildValues ( $ values ) ; return $ this ; }
Replace current values with the given values .
36,243
protected function buildValues ( $ values ) { $ result = [ ] ; foreach ( $ values as $ value ) { if ( ! is_null ( $ value ) ) { $ result [ ] = $ this -> buildValue ( $ value ) ; } } return $ result ; }
Build value instances from the given array .
36,244
public function getEntityAttributes ( ) : Collection { $ morphClass = $ this -> getMorphClass ( ) ; static :: $ entityAttributes = static :: $ entityAttributes ?? collect ( ) ; if ( ! static :: $ entityAttributes -> has ( $ morphClass ) && Schema :: hasTable ( config ( 'rinvex.attributes.tables.attribute_entity' ) ) ) ...
Get the entity attributes .
36,245
public function isEntityAttribute ( string $ key ) { $ key = $ this -> getEntityAttributeName ( $ key ) ; return $ this -> getEntityAttributes ( ) -> has ( $ key ) ; }
Check if the given key is an entity attribute .
36,246
public function getEntityAttribute ( string $ key ) { if ( $ this -> isRawEntityAttribute ( $ key ) ) { return $ this -> getEntityAttributeRelation ( $ key ) ; } return $ this -> getEntityAttributeValue ( $ key ) ; }
Get the entity attribute .
36,247
protected function getEntityAttributeValue ( string $ key ) { $ value = $ this -> getEntityAttributeRelation ( $ key ) ; if ( $ this -> getEntityAttributes ( ) -> get ( $ key ) -> is_collection ) { return $ value -> pluck ( 'content' ) ; } return ! is_null ( $ value ) ? $ value -> getAttribute ( 'content' ) : null ; }
Get the entity attribute value .
36,248
protected function getEntityAttributeRelation ( string $ key ) { $ key = $ this -> getEntityAttributeName ( $ key ) ; if ( $ this -> relationLoaded ( $ key ) ) { return $ this -> getRelation ( $ key ) ; } return $ this -> getRelationValue ( $ key ) ; }
Get the entity attribute relationship .
36,249
protected function setEntityAttributeValue ( Attribute $ attribute , $ value ) { if ( ! is_null ( $ value ) && ! $ value instanceof Value ) { $ model = Attribute :: getTypeModel ( $ attribute -> getAttribute ( 'type' ) ) ; $ instance = new $ model ( ) ; $ instance -> setAttribute ( 'entity_id' , $ this -> getKey ( ) ) ...
Set the entity attribute value .
36,250
public function handle ( Entity $ entity ) : void { $ this -> trash = $ entity -> getEntityAttributeValueTrash ( ) ; $ connection = $ entity -> getConnection ( ) ; $ connection -> beginTransaction ( ) ; try { foreach ( $ entity -> getEntityAttributes ( ) as $ attribute ) { if ( $ entity -> relationLoaded ( $ relation =...
Save values when an entity is saved .
36,251
protected function saveOrTrashValue ( Value $ value ) : void { if ( ! is_null ( $ value ) && ! $ this -> trashValue ( $ value ) ) { if ( $ value -> shouldPush ( ) ) { $ value -> push ( ) ; } else { $ value -> save ( ) ; } } }
Save or trash the given value according to it s content .
36,252
protected function trashValue ( Value $ value ) : bool { if ( ! is_null ( $ value -> getAttribute ( 'content' ) ) ) { return false ; } if ( $ value -> exists ) { $ this -> trash -> push ( $ value ) ; } return true ; }
Trash the given value .
36,253
public function build ( Entity $ entity ) : void { $ attributes = $ entity -> getEntityAttributes ( ) ; foreach ( $ attributes as $ attribute ) { $ relation = $ this -> getRelationClosure ( $ entity , $ attribute ) ; $ entity -> setEntityAttributeRelation ( $ attribute -> getAttribute ( 'slug' ) , $ relation ) ; } }
Build the relations for the entity attributes .
36,254
public function setSlugAttribute ( $ value ) : void { $ this -> attributes [ 'slug' ] = str_slug ( $ value , $ this -> getSlugOptions ( ) -> slugSeparator , $ this -> getSlugOptions ( ) -> slugLanguage ) ; }
Enforce clean slugs .
36,255
public static function typeMap ( array $ map = null , $ merge = true ) { if ( is_array ( $ map ) ) { static :: $ typeMap = $ merge && static :: $ typeMap ? $ map + static :: $ typeMap : $ map ; } return static :: $ typeMap ; }
Set or get the type map for attribute types .
36,256
public function diff ( $ from , $ to = null ) { $ from = $ this -> getDatetimeObject ( $ from ) ; $ to = $ this -> getDatetimeObject ( $ to ) ; return $ this -> formatter -> formatDiff ( $ from , $ to ) ; }
Returns a single number of years months days hours minutes or seconds between the specified date times .
36,257
public function getDatetimeObject ( $ datetime = null ) { if ( $ datetime instanceof DateTimeInterface ) { return $ datetime ; } if ( is_integer ( $ datetime ) ) { $ datetime = date ( 'Y-m-d H:i:s' , $ datetime ) ; } return new DateTime ( $ datetime ) ; }
Returns a DateTime instance for the given datetime
36,258
public function formatDiff ( DateTimeInterface $ from , DateTimeInterface $ to ) { static $ units = array ( 'y' => 'year' , 'm' => 'month' , 'd' => 'day' , 'h' => 'hour' , 'i' => 'minute' , 's' => 'second' ) ; $ diff = $ to -> diff ( $ from ) ; foreach ( $ units as $ attribute => $ unit ) { $ count = $ diff -> $ attrib...
Returns a formatted diff for the given from and to datetimes
36,259
public function getDiffMessage ( $ count , $ invert , $ unit ) { if ( 0 === $ count ) { throw new \ InvalidArgumentException ( 'The count must not be null.' ) ; } $ unit = strtolower ( $ unit ) ; if ( ! in_array ( $ unit , array ( 'year' , 'month' , 'day' , 'hour' , 'minute' , 'second' ) ) ) { throw new \ InvalidArgume...
Returns the diff message for the specified count and unit
36,260
public function creating ( BanContract $ ban ) : void { $ bannedBy = auth ( ) -> user ( ) ; if ( $ bannedBy && is_null ( $ ban -> created_by_type ) && is_null ( $ ban -> created_by_id ) ) { $ ban -> fill ( [ 'created_by_type' => $ bannedBy -> getMorphClass ( ) , 'created_by_id' => $ bannedBy -> getKey ( ) , ] ) ; } }
Handle the creating event for the Ban model .
36,261
public function created ( BanContract $ ban ) : void { $ bannable = $ ban -> bannable ( ) -> withBanned ( ) -> first ( ) ; $ bannable -> setBannedFlag ( $ ban -> created_at ) -> save ( ) ; event ( new ModelWasBanned ( $ bannable , $ ban ) ) ; }
Handle the created event for the Ban model .
36,262
public function deleted ( BanContract $ ban ) : void { $ bannable = $ ban -> bannable ( ) -> withBanned ( ) -> first ( ) ; if ( $ bannable -> bans -> count ( ) === 0 ) { $ bannable -> unsetBannedFlag ( ) -> save ( ) ; event ( new ModelWasUnbanned ( $ bannable ) ) ; } }
Handle the deleted event for the Ban model .
36,263
public function unban ( BannableContract $ bannable ) : void { $ bannable -> bans -> each ( function ( $ ban ) { $ ban -> delete ( ) ; } ) ; }
Unban entity .
36,264
public function deleteExpiredBans ( ) : void { $ bans = Ban :: query ( ) -> where ( 'expired_at' , '<=' , Carbon :: now ( ) -> format ( 'Y-m-d H:i:s' ) ) -> get ( ) ; $ bans -> each ( function ( $ ban ) { $ ban -> delete ( ) ; } ) ; }
Delete all expired Ban models .
36,265
protected function addWithBanned ( Builder $ builder ) : void { $ builder -> macro ( 'withBanned' , function ( Builder $ builder ) { return $ builder -> withoutGlobalScope ( $ this ) ; } ) ; }
Add the withBanned extension to the builder .
36,266
protected function addWithoutBanned ( Builder $ builder ) : void { $ builder -> macro ( 'withoutBanned' , function ( Builder $ builder ) { return $ builder -> withoutGlobalScope ( $ this ) -> whereNull ( 'banned_at' ) ; } ) ; }
Add the withoutBanned extension to the builder .
36,267
protected function addOnlyBanned ( Builder $ builder ) : void { $ builder -> macro ( 'onlyBanned' , function ( Builder $ builder ) { return $ builder -> withoutGlobalScope ( $ this ) -> whereNotNull ( 'banned_at' ) ; } ) ; }
Add the onlyBanned extension to the builder .
36,268
protected function registerConsoleCommands ( ) : void { if ( $ this -> app -> runningInConsole ( ) ) { $ this -> app -> bind ( 'command.ban:delete-expired' , DeleteExpiredBans :: class ) ; $ this -> commands ( [ 'command.ban:delete-expired' , ] ) ; } }
Register Ban s console commands .
36,269
protected function registerContracts ( ) : void { $ this -> app -> bind ( BanContract :: class , Ban :: class ) ; $ this -> app -> singleton ( BanServiceContract :: class , BanService :: class ) ; }
Register Ban s classes in the container .
36,270
protected function registerPublishes ( ) : void { if ( $ this -> app -> runningInConsole ( ) ) { $ migrationsPath = __DIR__ . '/../../database/migrations' ; $ this -> publishes ( [ $ migrationsPath => database_path ( 'migrations' ) , ] , 'migrations' ) ; $ this -> loadMigrationsFrom ( $ migrationsPath ) ; } }
Setup the resource publishing groups for Ban .
36,271
public function setExpiredAtAttribute ( $ value ) : void { if ( ! is_null ( $ value ) && ! $ value instanceof Carbon ) { $ value = Carbon :: parse ( $ value ) ; } $ this -> attributes [ 'expired_at' ] = $ value ; }
Expired timestamp mutator .
36,272
public function merge ( self $ otherMetadata ) : self { return new self ( array_merge ( $ this -> values , $ otherMetadata -> values ) ) ; }
Merges the values of this and the other instance .
36,273
public function isMatchedBy ( DomainMessage $ domainMessage ) : bool { if ( $ this -> aggregateRootTypes ) { throw new CriteriaNotSupportedException ( 'Cannot match criteria based on aggregate root types.' ) ; } if ( $ this -> aggregateRootIds && ! in_array ( $ domainMessage -> getId ( ) , $ this -> aggregateRootIds ) ...
Determine if a domain message is matched by this criteria .
36,274
public static function manufacture ( $ partId , $ manufacturerId , $ manufacturerName ) { $ part = new self ( ) ; $ part -> apply ( new PartWasManufacturedEvent ( $ partId , $ manufacturerId , $ manufacturerName ) ) ; return $ part ; }
Factory method to create a part .
36,275
protected function handleManufacturePartCommand ( ManufacturePartCommand $ command ) { $ part = Part :: manufacture ( $ command -> partId , $ command -> manufacturerId , $ command -> manufacturerName ) ; $ this -> repository -> save ( $ part ) ; }
A new part aggregate root is created and added to the repository .
36,276
public function andMetadata ( Metadata $ metadata ) : self { $ newMetadata = $ this -> metadata -> merge ( $ metadata ) ; return new self ( $ this -> id , $ this -> playhead , $ newMetadata , $ this -> payload , $ this -> recordedOn ) ; }
Creates a new DomainMessage with all things equal except metadata .
36,277
public function apply ( $ event ) : void { $ this -> handleRecursively ( $ event ) ; ++ $ this -> playhead ; $ this -> uncommittedEvents [ ] = DomainMessage :: recordNow ( $ this -> getAggregateRootId ( ) , $ this -> playhead , new Metadata ( [ ] ) , $ event ) ; }
Applies an event . The event is added to the AggregateRoot s list of uncommitted events .
36,278
public function initializeState ( DomainEventStream $ stream ) : void { foreach ( $ stream as $ message ) { ++ $ this -> playhead ; $ this -> handleRecursively ( $ message -> getPayload ( ) ) ; } }
Initializes the aggregate using the given history of events .
36,279
protected function handleJobSeekerStartLookingForWorkCommand ( JobSeekerStartLookingForWorkCommand $ command ) { $ jobSeeker = JobSeeker :: startLookingForWork ( $ command -> jobSeekerId ) ; $ this -> repository -> save ( $ jobSeeker ) ; }
A new job seeker aggregate root is created and added to the repository .
36,280
public function all ( $ project , array $ params = [ ] ) { $ this -> issueCategories = $ this -> retrieveAll ( '/projects/' . $ project . '/issue_categories.json' , $ params ) ; return $ this -> issueCategories ; }
List issue categories .
36,281
public function getIdByName ( $ project , $ name ) { $ arr = $ this -> listing ( $ project ) ; if ( ! isset ( $ arr [ $ name ] ) ) { return false ; } return $ arr [ ( string ) $ name ] ; }
Get a category id given its name and related project .
36,282
public function update ( $ id , array $ params = [ ] ) { $ defaults = [ 'role_ids' => null , ] ; $ params = $ this -> sanitizeParams ( $ defaults , $ params ) ; if ( ! isset ( $ params [ 'role_ids' ] ) ) { throw new \ Exception ( 'Missing mandatory parameters' ) ; } $ xml = $ this -> buildXML ( $ params ) ; return $ th...
Update membership information s by id .
36,283
public function removeMember ( $ projectId , $ userId , array $ params = [ ] ) { $ memberships = $ this -> all ( $ projectId , $ params ) ; if ( ! isset ( $ memberships [ 'memberships' ] ) || ! is_array ( $ memberships [ 'memberships' ] ) ) { return ; } $ removed = false ; foreach ( $ memberships [ 'memberships' ] as $...
Delete membership of project by user id .
36,284
private function buildXML ( array $ params = [ ] ) { $ xml = new \ SimpleXMLElement ( '<?xml version="1.0"?><membership></membership>' ) ; foreach ( $ params as $ k => $ v ) { if ( 'role_ids' === $ k && is_array ( $ v ) ) { $ item = $ xml -> addChild ( $ k ) ; $ item -> addAttribute ( 'type' , 'array' ) ; foreach ( $ v...
Build the XML for a membership .
36,285
public function show ( $ id , array $ params = [ ] ) { if ( isset ( $ params [ 'include' ] ) && is_array ( $ params [ 'include' ] ) ) { $ params [ 'include' ] = implode ( ',' , $ params [ 'include' ] ) ; } return $ this -> get ( '/issues/' . urlencode ( $ id ) . '.json?' . http_build_query ( $ params ) ) ; }
Get extended information about an issue gitven its id .
36,286
private function buildXML ( array $ params = [ ] ) { $ xml = new \ SimpleXMLElement ( '<?xml version="1.0"?><issue></issue>' ) ; foreach ( $ params as $ k => $ v ) { if ( 'custom_fields' === $ k && is_array ( $ v ) ) { $ this -> attachCustomFieldXML ( $ xml , $ v ) ; } elseif ( 'watcher_user_ids' === $ k && is_array ( ...
Build the XML for an issue .
36,287
public function update ( $ id , array $ params ) { $ defaults = [ 'id' => $ id , 'subject' => null , 'notes' => null , 'private_notes' => false , 'category_id' => null , 'priority_id' => null , 'status_id' => null , 'tracker_id' => null , 'assigned_to_id' => null , 'due_date' => null , ] ; $ params = $ this -> cleanPar...
Update issue information s by username repo and issue number . Requires authentication .
36,288
private function cleanParams ( array $ params = [ ] ) { if ( isset ( $ params [ 'project' ] ) ) { $ apiProject = $ this -> client -> project ; $ params [ 'project_id' ] = $ apiProject -> getIdByName ( $ params [ 'project' ] ) ; unset ( $ params [ 'project' ] ) ; if ( isset ( $ params [ 'category' ] ) ) { $ apiIssueCate...
Transforms literal identifiers to integer ids .
36,289
public function attachMany ( $ id , array $ attachments ) { $ request = [ ] ; $ request [ 'issue' ] = [ 'id' => $ id , 'uploads' => $ attachments , ] ; return $ this -> put ( '/issues/' . $ id . '.json' , json_encode ( $ request ) ) ; }
Attach files to an issue . Requires authentication .
36,290
public function create ( $ issueId , array $ params = [ ] ) { $ defaults = [ 'relation_type' => 'relates' , 'issue_to_id' => null , 'delay' => null , ] ; $ params = $ this -> sanitizeParams ( $ defaults , $ params ) ; $ params = json_encode ( [ 'relation' => $ params ] ) ; return json_decode ( $ this -> post ( '/issues...
Create a new issue relation .
36,291
public function decode ( $ json ) { if ( empty ( $ json ) ) { return '' ; } $ decoded = json_decode ( $ json , true ) ; if ( null !== $ decoded ) { return $ decoded ; } if ( JSON_ERROR_NONE === json_last_error ( ) ) { return $ json ; } return self :: $ jsonErrors [ json_last_error ( ) ] ; }
Decodes json response .
36,292
public function setPort ( $ port = null ) { if ( null !== $ port ) { $ this -> port = ( int ) $ port ; } return $ this ; }
Set the port of the connection .
36,293
public function getPort ( ) { if ( null !== $ this -> port ) { return $ this -> port ; } $ tmp = parse_url ( $ this -> getUrl ( ) ) ; if ( isset ( $ tmp [ 'port' ] ) ) { $ this -> setPort ( $ tmp [ 'port' ] ) ; } elseif ( isset ( $ tmp [ 'scheme' ] ) ) { $ this -> setPort ( self :: $ defaultPorts [ $ tmp [ 'scheme' ] ]...
Returns the port of the current connection if not set it will try to guess the port from the url of the client .
36,294
public function prepareRequest ( $ path , $ method = 'GET' , $ data = '' ) { $ this -> responseCode = null ; $ curl = curl_init ( ) ; $ this -> setCurlOption ( CURLOPT_VERBOSE , 0 ) ; $ this -> setCurlOption ( CURLOPT_HEADER , 0 ) ; $ this -> setCurlOption ( CURLOPT_RETURNTRANSFER , 1 ) ; if ( $ this -> apikeyOrUsernam...
Prepare the request by setting the cURL options .
36,295
public function processCurlResponse ( $ response , $ contentType ) { if ( $ response ) { if ( 0 === strpos ( $ contentType , 'application/xml' ) ) { return new \ SimpleXMLElement ( $ response ) ; } return $ response ; } return false ; }
Process the cURL response .
36,296
public function addUser ( $ id , $ userId ) { $ xml = new \ SimpleXMLElement ( '<?xml version="1.0"?><user_id>' . $ userId . '</user_id>' ) ; return $ this -> post ( '/groups/' . $ id . '/users.xml' , $ xml -> asXML ( ) ) ; }
Adds an existing user to a group .
36,297
public function getIdByUsername ( $ username , array $ params = [ ] ) { $ arr = $ this -> listing ( false , $ params ) ; if ( ! isset ( $ arr [ $ username ] ) ) { return false ; } return $ arr [ ( string ) $ username ] ; }
Get a user id given its username .
36,298
public function update ( $ id , array $ params ) { $ defaults = [ 'id' => $ id , 'login' => null , 'password' => null , 'lastname' => null , 'firstname' => null , 'mail' => null , ] ; $ params = $ this -> sanitizeParams ( $ defaults , $ params ) ; $ xml = new \ SimpleXMLElement ( '<?xml version="1.0"?><user></user>' ) ...
Update user s information .
36,299
public function all ( $ project , array $ params = [ ] ) { $ this -> versions = $ this -> retrieveAll ( '/projects/' . $ project . '/versions.json' , $ params ) ; return $ this -> versions ; }
List versions .