idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
39,600
public function offsetSet ( $ name , $ value ) { if ( is_int ( $ name ) ) { parent :: offsetSet ( $ name , $ value ) ; return ; } $ param = new Parameter ( $ this -> root , $ name , $ value ) ; $ this -> parameters [ $ param -> name ] = $ param ; }
Creates a new parameter .
39,601
public function offsetUnset ( $ name ) { if ( is_int ( $ name ) ) { parent :: offsetUnset ( $ name ) ; return ; } unset ( $ this -> parameters [ strtoupper ( $ name ) ] ) ; }
Removes one or more parameters with the specified name .
39,602
public function isFree ( DateTimeInterface $ start , DatetimeInterface $ end ) { foreach ( $ this -> select ( 'FREEBUSY' ) as $ freebusy ) { if ( isset ( $ freebusy [ 'FBTYPE' ] ) && 'BUSY' !== strtoupper ( substr ( ( string ) $ freebusy [ 'FBTYPE' ] , 0 , 4 ) ) ) { continue ; } $ periods = explode ( ',' , ( string ) $...
Checks based on the contained FREEBUSY information if a timeslot is available .
39,603
public function setTimeRange ( DateTimeInterface $ start = null , DateTimeInterface $ end = null ) { if ( ! $ start ) { $ start = new DateTimeImmutable ( Settings :: $ minDate ) ; } if ( ! $ end ) { $ end = new DateTimeImmutable ( Settings :: $ maxDate ) ; } $ this -> start = $ start ; $ this -> end = $ end ; }
Sets the time range .
39,604
public function getResult ( ) { $ fbData = new FreeBusyData ( $ this -> start -> getTimeStamp ( ) , $ this -> end -> getTimeStamp ( ) ) ; if ( $ this -> vavailability ) { $ this -> calculateAvailability ( $ fbData , $ this -> vavailability ) ; } $ this -> calculateBusy ( $ fbData , $ this -> objects ) ; return $ this -...
Parses the input data and returns a correct VFREEBUSY object wrapped in a VCALENDAR .
39,605
protected function generateFreeBusyCalendar ( FreeBusyData $ fbData ) { if ( $ this -> baseObject ) { $ calendar = $ this -> baseObject ; } else { $ calendar = new VCalendar ( ) ; } $ vfreebusy = $ calendar -> createComponent ( 'VFREEBUSY' ) ; $ calendar -> add ( $ vfreebusy ) ; if ( $ this -> start ) { $ dtstart = $ c...
This method takes a FreeBusyData object and generates the VCALENDAR object associated with it .
39,606
public function getScheduleStatus ( ) { if ( ! $ this -> scheduleStatus ) { return false ; } else { list ( $ scheduleStatus ) = explode ( ';' , $ this -> scheduleStatus ) ; return $ scheduleStatus ; } }
Returns the schedule status as a string .
39,607
public function convert ( Component \ VCard $ input , $ targetVersion ) { $ inputVersion = $ input -> getDocumentType ( ) ; if ( $ inputVersion === $ targetVersion ) { return clone $ input ; } if ( ! in_array ( $ inputVersion , [ Document :: VCARD21 , Document :: VCARD30 , Document :: VCARD40 ] ) ) { throw new \ Invali...
Converts a vCard object to a new version .
39,608
protected function convertBinaryToUri ( Component \ VCard $ output , Property \ Binary $ newProperty , array & $ parameters ) { $ value = $ newProperty -> getValue ( ) ; $ newProperty = $ output -> createProperty ( $ newProperty -> name , null , [ ] , 'URI' ) ; $ mimeType = 'application/octet-stream' ; if ( isset ( $ p...
Converts a BINARY property to a URI property .
39,609
protected function convertUriToBinary ( Component \ VCard $ output , Property \ Uri $ newProperty ) { $ value = $ newProperty -> getValue ( ) ; if ( 'data:' !== substr ( $ value , 0 , 5 ) ) { return $ newProperty ; } $ newProperty = $ output -> createProperty ( $ newProperty -> name , null , [ ] , 'BINARY' ) ; $ mimeTy...
Converts a URI property to a BINARY property .
39,610
protected function convertParameters40 ( Property $ newProperty , array $ parameters ) { foreach ( $ parameters as $ param ) { if ( $ param -> noName ) { $ param -> noName = false ; } switch ( $ param -> name ) { case 'TYPE' : foreach ( $ param -> getParts ( ) as $ paramPart ) { if ( 'PREF' === strtoupper ( $ paramPart...
Adds parameters to a new property for vCard 4 . 0 .
39,611
protected function convertParameters30 ( Property $ newProperty , array $ parameters ) { foreach ( $ parameters as $ param ) { if ( $ param -> noName ) { $ param -> noName = false ; } switch ( $ param -> name ) { case 'ENCODING' : if ( 'QUOTED-PRINTABLE' !== strtoupper ( $ param -> getValue ( ) ) ) { $ newProperty -> a...
Adds parameters to a new property for vCard 3 . 0 .
39,612
public function assertVObjectEqualsVObject ( $ expected , $ actual , $ message = '' ) { $ self = $ this ; $ getObj = function ( $ input ) use ( $ self ) { if ( is_resource ( $ input ) ) { $ input = stream_get_contents ( $ input ) ; } if ( is_string ( $ input ) ) { $ input = Reader :: read ( $ input ) ; } if ( ! $ input...
This method tests wether two vcards or icalendar objects are semantically identical .
39,613
public function getDocumentType ( ) { if ( ! $ this -> version ) { $ version = ( string ) $ this -> VERSION ; switch ( $ version ) { case '2.1' : $ this -> version = self :: VCARD21 ; break ; case '3.0' : $ this -> version = self :: VCARD30 ; break ; case '4.0' : $ this -> version = self :: VCARD40 ; break ; default : ...
Returns the current document type .
39,614
public function preferred ( $ propertyName ) { $ preferred = null ; $ lastPref = 101 ; foreach ( $ this -> select ( $ propertyName ) as $ field ) { $ pref = 101 ; if ( isset ( $ field [ 'TYPE' ] ) && $ field [ 'TYPE' ] -> has ( 'PREF' ) ) { $ pref = 1 ; } elseif ( isset ( $ field [ 'PREF' ] ) ) { $ pref = $ field [ 'PR...
Returns a preferred field .
39,615
public function jsonSerialize ( ) { $ properties = [ ] ; foreach ( $ this -> children ( ) as $ child ) { $ properties [ ] = $ child -> jsonSerialize ( ) ; } return [ strtolower ( $ this -> name ) , $ properties , ] ; }
This method returns an array with the representation as it should be encoded in json . This is used to create jCard or jCal documents .
39,616
public function getClassNameForPropertyName ( $ propertyName ) { $ className = parent :: getClassNameForPropertyName ( $ propertyName ) ; if ( 'Sabre\\VObject\\Property\\Binary' == $ className && self :: VCARD40 === $ this -> getDocumentType ( ) ) { return 'Sabre\\VObject\\Property\\Uri' ; } return $ className ; }
Returns the default class for a property name .
39,617
public function parse ( $ input = null , $ options = 0 ) { $ this -> root = null ; if ( ! is_null ( $ input ) ) { $ this -> setInput ( $ input ) ; } if ( 0 !== $ options ) { $ this -> options = $ options ; } $ this -> parseDocument ( ) ; return $ this -> root ; }
Parses an iCalendar or vCard file .
39,618
public function setCharset ( $ charset ) { if ( ! in_array ( $ charset , self :: $ SUPPORTED_CHARSETS ) ) { throw new \ InvalidArgumentException ( 'Unsupported encoding. (Supported encodings: ' . implode ( ', ' , self :: $ SUPPORTED_CHARSETS ) . ')' ) ; } $ this -> charset = $ charset ; }
By default all input will be assumed to be UTF - 8 .
39,619
public function setInput ( $ input ) { $ this -> lineIndex = 0 ; $ this -> startLine = 0 ; if ( is_string ( $ input ) ) { $ stream = fopen ( 'php://temp' , 'r+' ) ; fwrite ( $ stream , $ input ) ; rewind ( $ stream ) ; $ this -> input = $ stream ; } elseif ( is_resource ( $ input ) ) { $ this -> input = $ input ; } els...
Sets the input buffer . Must be a string or stream .
39,620
protected function parseDocument ( ) { $ line = $ this -> readLine ( ) ; if ( 3 <= strlen ( $ line ) && 0xef === ord ( $ line [ 0 ] ) && 0xbb === ord ( $ line [ 1 ] ) && 0xbf === ord ( $ line [ 2 ] ) ) { $ line = substr ( $ line , 3 ) ; } switch ( strtoupper ( $ line ) ) { case 'BEGIN:VCALENDAR' : $ class = VCalendar :...
Parses an entire document .
39,621
protected function parseLine ( $ line ) { if ( 'BEGIN:' === strtoupper ( substr ( $ line , 0 , 6 ) ) ) { if ( substr ( $ line , 6 ) === $ this -> root -> name ) { throw new ParseException ( 'Invalid MimeDir file. Unexpected component: "' . $ line . '" in document type ' . $ this -> root -> name ) ; } $ component = $ th...
Parses a line and if it hits a component it will also attempt to parse the entire component .
39,622
protected function readLine ( ) { if ( ! \ is_null ( $ this -> lineBuffer ) ) { $ rawLine = $ this -> lineBuffer ; $ this -> lineBuffer = null ; } else { do { $ eof = \ feof ( $ this -> input ) ; $ rawLine = \ fgets ( $ this -> input ) ; if ( $ eof || ( \ feof ( $ this -> input ) && false === $ rawLine ) ) { throw new ...
Reads a single line from the buffer .
39,623
public static function unescapeValue ( $ input , $ delimiter = ';' ) { $ regex = '# (?: (\\\\ (?: \\\\ | N | n | ; | , ) )' ; if ( $ delimiter ) { $ regex .= ' | (' . $ delimiter . ')' ; } $ regex .= ') #x' ; $ matches = preg_split ( $ regex , $ input , - 1 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ) ; $ result...
Unescapes a property value .
39,624
private function extractQuotedPrintableValue ( ) { $ regex = '/^ (?: [^:])+ # Anything but a colon (?: "[^"]")* # A parameter in double quotes : # start of the value we really care about (.*)$ /xs' ; preg_match ( $ regex , $ this -> rawLine , $ matches ) ; $ value = $ ...
Gets the full quoted printable value .
39,625
protected function showHelp ( ) { $ this -> log ( 'Usage:' , 'yellow' ) ; $ this -> log ( ' vobject [options] command [arguments]' ) ; $ this -> log ( '' ) ; $ this -> log ( 'Options:' , 'yellow' ) ; $ this -> log ( $ this -> colorize ( 'green' , ' -q ' ) . "Don't output anything." ) ; $ this -> log ( $ th...
Shows the help message .
39,626
protected function validate ( Component $ vObj ) { $ returnCode = 0 ; switch ( $ vObj -> name ) { case 'VCALENDAR' : $ this -> log ( 'iCalendar: ' . ( string ) $ vObj -> VERSION ) ; break ; case 'VCARD' : $ this -> log ( 'vCard: ' . ( string ) $ vObj -> VERSION ) ; break ; } $ warnings = $ vObj -> validate ( ) ; if ( !...
Validates a VObject file .
39,627
protected function repair ( Component $ vObj ) { $ returnCode = 0 ; switch ( $ vObj -> name ) { case 'VCALENDAR' : $ this -> log ( 'iCalendar: ' . ( string ) $ vObj -> VERSION ) ; break ; case 'VCARD' : $ this -> log ( 'vCard: ' . ( string ) $ vObj -> VERSION ) ; break ; } $ warnings = $ vObj -> validate ( Node :: REPA...
Repairs a VObject file .
39,628
protected function convert ( $ vObj ) { $ json = false ; $ convertVersion = null ; $ forceInput = null ; switch ( $ this -> format ) { case 'json' : $ json = true ; if ( 'VCARD' === $ vObj -> name ) { $ convertVersion = Document :: VCARD40 ; } break ; case 'jcard' : $ json = true ; $ forceInput = 'VCARD' ; $ convertVer...
Converts a vObject file to a new format .
39,629
protected function colorize ( $ color , $ str , $ resetTo = 'default' ) { $ colors = [ 'cyan' => '1;36' , 'red' => '1;31' , 'yellow' => '1;33' , 'blue' => '0;34' , 'green' => '0;32' , 'default' => '0' , 'purple' => '0;35' , ] ; return "\033[" . $ colors [ $ color ] . 'm' . $ str . "\033[" . $ colors [ $ resetTo ] . 'm'...
Returns an ansi color string for a color name .
39,630
protected function cWrite ( $ color , $ str ) { fwrite ( $ this -> stdout , $ this -> colorize ( $ color , $ str ) ) ; }
Writes out a string in specific color .
39,631
protected function serializeProperty ( Property $ property ) { if ( $ property -> group ) { $ this -> cWrite ( 'default' , $ property -> group ) ; $ this -> cWrite ( 'red' , '.' ) ; } $ this -> cWrite ( 'yellow' , $ property -> name ) ; foreach ( $ property -> parameters as $ param ) { $ this -> cWrite ( 'red' , ';' ) ...
Colorizes a property .
39,632
protected function parseArguments ( array $ argv ) { $ positional = [ ] ; $ options = [ ] ; for ( $ ii = 0 ; $ ii < count ( $ argv ) ; ++ $ ii ) { if ( 0 === $ ii ) { continue ; } $ v = $ argv [ $ ii ] ; if ( '--' === substr ( $ v , 0 , 2 ) ) { $ optionName = substr ( $ v , 2 ) ; $ optionValue = true ; if ( strpos ( $ ...
Parses the list of arguments .
39,633
protected function readInput ( ) { if ( ! $ this -> parser ) { if ( '-' !== $ this -> inputPath ) { $ this -> stdin = fopen ( $ this -> inputPath , 'r' ) ; } if ( 'mimedir' === $ this -> inputFormat ) { $ this -> parser = new Parser \ MimeDir ( $ this -> stdin , ( $ this -> forgiving ? Reader :: OPTION_FORGIVING : 0 ) ...
Reads the input file .
39,634
protected function log ( $ msg , $ color = 'default' ) { if ( ! $ this -> quiet ) { if ( 'default' !== $ color ) { $ msg = $ this -> colorize ( $ color , $ msg ) ; } fwrite ( $ this -> stderr , $ msg . "\n" ) ; } }
Sends a message to STDERR .
39,635
public function processMessage ( Message $ itipMessage , VCalendar $ existingObject = null ) { if ( 'VEVENT' !== $ itipMessage -> component ) { return false ; } switch ( $ itipMessage -> method ) { case 'REQUEST' : return $ this -> processMessageRequest ( $ itipMessage , $ existingObject ) ; case 'CANCEL' : return $ th...
This method is used to process an incoming itip message .
39,636
public function parseEvent ( $ calendar = null , $ userHref , $ oldCalendar = null ) { if ( $ oldCalendar ) { if ( is_string ( $ oldCalendar ) ) { $ oldCalendar = Reader :: read ( $ oldCalendar ) ; } if ( ! isset ( $ oldCalendar -> VEVENT ) ) { return [ ] ; } $ oldEventInfo = $ this -> parseEventInfo ( $ oldCalendar ) ...
This function parses a VCALENDAR object and figure out if any messages need to be sent .
39,637
protected function processMessageRequest ( Message $ itipMessage , VCalendar $ existingObject = null ) { if ( ! $ existingObject ) { $ existingObject = new VCalendar ( ) ; foreach ( $ itipMessage -> message -> getComponents ( ) as $ component ) { $ existingObject -> add ( clone $ component ) ; } } else { foreach ( $ ex...
Processes incoming REQUEST messages .
39,638
protected function processMessageCancel ( Message $ itipMessage , VCalendar $ existingObject = null ) { if ( ! $ existingObject ) { } else { foreach ( $ existingObject -> VEVENT as $ vevent ) { $ vevent -> STATUS = 'CANCELLED' ; $ vevent -> SEQUENCE = $ itipMessage -> sequence ; } } return $ existingObject ; }
Processes incoming CANCEL messages .
39,639
public static function getTimeZone ( $ tzid , Component $ vcalendar = null , $ failIfUncertain = false ) { if ( '(' !== $ tzid [ 0 ] ) { $ tzIdentifiers = \ DateTimeZone :: listIdentifiers ( ) ; try { if ( ( in_array ( $ tzid , $ tzIdentifiers ) ) || ( preg_match ( '/^GMT(\+|-)([0-9]{4})$/' , $ tzid , $ matches ) ) || ...
This method will try to find out the correct timezone for an iCalendar date - time value .
39,640
public static function loadTzMaps ( ) { if ( ! is_null ( self :: $ map ) ) { return ; } self :: $ map = array_merge ( include __DIR__ . '/timezonedata/windowszones.php' , include __DIR__ . '/timezonedata/lotuszones.php' , include __DIR__ . '/timezonedata/exchangezones.php' , include __DIR__ . '/timezonedata/php-workaro...
This method will load in all the tz mapping information if it s not yet done .
39,641
public function setQuotedPrintableValue ( $ val ) { $ val = quoted_printable_decode ( $ val ) ; $ regex = '# (?<!\\\\) ; #x' ; $ matches = preg_split ( $ regex , $ val ) ; $ this -> setValue ( $ matches ) ; }
Sets the value as a quoted - printable encoded string .
39,642
public function setXmlValue ( array $ value ) { $ value = array_map ( function ( $ value ) { return 'true' === $ value ; } , $ value ) ; parent :: setXmlValue ( $ value ) ; }
Hydrate data from a XML subtree as it would appear in a xCard or xCal object .
39,643
public function add ( ) { $ arguments = func_get_args ( ) ; if ( $ arguments [ 0 ] instanceof Node ) { if ( isset ( $ arguments [ 1 ] ) ) { throw new \ InvalidArgumentException ( 'The second argument must not be specified, when passing a VObject Node' ) ; } $ arguments [ 0 ] -> parent = $ this ; $ newNode = $ arguments...
Adds a new property or component and returns the new item .
39,644
public function remove ( $ item ) { if ( is_string ( $ item ) ) { if ( false === strpos ( $ item , '.' ) ) { unset ( $ this -> children [ strtoupper ( $ item ) ] ) ; return ; } foreach ( $ this -> select ( $ item ) as $ child ) { $ this -> remove ( $ child ) ; } } else { foreach ( $ this -> select ( $ item -> name ) as...
This method removes a component or property from this component .
39,645
public function children ( ) { $ result = [ ] ; foreach ( $ this -> children as $ childGroup ) { $ result = array_merge ( $ result , $ childGroup ) ; } return $ result ; }
Returns a flat list of all the properties and components in this component .
39,646
public function getComponents ( ) { $ result = [ ] ; foreach ( $ this -> children as $ childGroup ) { foreach ( $ childGroup as $ child ) { if ( $ child instanceof self ) { $ result [ ] = $ child ; } } } return $ result ; }
This method only returns a list of sub - components . Properties are ignored .
39,647
public function select ( $ name ) { $ group = null ; $ name = strtoupper ( $ name ) ; if ( false !== strpos ( $ name , '.' ) ) { list ( $ group , $ name ) = explode ( '.' , $ name , 2 ) ; } if ( '' === $ name ) { $ name = null ; } if ( ! is_null ( $ name ) ) { $ result = isset ( $ this -> children [ $ name ] ) ? $ this...
Returns an array with elements that match the specified name .
39,648
public function setJsonValue ( array $ value ) { $ value = array_map ( function ( $ item ) { return strtr ( implode ( '/' , $ item ) , [ ':' => '' , '-' => '' ] ) ; } , $ value ) ; parent :: setJsonValue ( $ value ) ; }
Sets the json value as it would appear in a jCard or jCal object .
39,649
public function fastForward ( DateTimeInterface $ dt ) { while ( $ this -> valid ( ) && $ this -> currentDate < $ dt ) { $ this -> next ( ) ; } }
This method allows you to quickly go to the next occurrence after the specified date .
39,650
public function addValue ( $ part ) { if ( is_null ( $ this -> value ) ) { $ this -> value = $ part ; } else { $ this -> value = array_merge ( ( array ) $ this -> value , ( array ) $ part ) ; } }
Adds a value to this parameter .
39,651
public function getIterator ( ) { if ( ! is_null ( $ this -> iterator ) ) { return $ this -> iterator ; } return $ this -> iterator = new ArrayIterator ( ( array ) $ this -> value ) ; }
Returns the iterator for this object .
39,652
public function valid ( ) { if ( null === $ this -> currentDate ) { return false ; } if ( ! is_null ( $ this -> count ) ) { return $ this -> counter < $ this -> count ; } return is_null ( $ this -> until ) || $ this -> currentDate <= $ this -> until ; }
Returns whether the current item is a valid item for the recurrence iterator . This will return false if we ve gone beyond the UNTIL or COUNT statements .
39,653
protected function nextDaily ( ) { if ( ! $ this -> byHour && ! $ this -> byDay ) { $ this -> currentDate = $ this -> currentDate -> modify ( '+' . $ this -> interval . ' days' ) ; return ; } if ( ! empty ( $ this -> byHour ) ) { $ recurrenceHours = $ this -> getHours ( ) ; } if ( ! empty ( $ this -> byDay ) ) { $ recu...
Does the processing for advancing the iterator for daily frequency .
39,654
protected function nextWeekly ( ) { if ( ! $ this -> byHour && ! $ this -> byDay ) { $ this -> currentDate = $ this -> currentDate -> modify ( '+' . $ this -> interval . ' weeks' ) ; return ; } if ( $ this -> byHour ) { $ recurrenceHours = $ this -> getHours ( ) ; } if ( $ this -> byDay ) { $ recurrenceDays = $ this ->...
Does the processing for advancing the iterator for weekly frequency .
39,655
protected function nextMonthly ( ) { $ currentDayOfMonth = $ this -> currentDate -> format ( 'j' ) ; if ( ! $ this -> byMonthDay && ! $ this -> byDay ) { if ( $ currentDayOfMonth < 29 ) { $ this -> currentDate = $ this -> currentDate -> modify ( '+' . $ this -> interval . ' months' ) ; } else { $ increase = 0 ; do { ++...
Does the processing for advancing the iterator for monthly frequency .
39,656
public function offsetSet ( $ offset , $ value ) { $ iterator = $ this -> getIterator ( ) ; $ iterator -> offsetSet ( $ offset , $ value ) ; }
Sets an item through ArrayAccess .
39,657
public function parameters ( ) { $ parameters = parent :: parameters ( ) ; if ( ! isset ( $ parameters [ 'VALUE' ] ) && in_array ( $ this -> name , [ 'URL' , 'PHOTO' ] ) ) { $ parameters [ 'VALUE' ] = new Parameter ( $ this -> root , 'VALUE' , 'URI' ) ; } return $ parameters ; }
Returns an iterable list of children .
39,658
public static function writeXml ( Component $ component ) { $ writer = new Xml \ Writer ( ) ; $ writer -> openMemory ( ) ; $ writer -> setIndent ( true ) ; $ writer -> startDocument ( '1.0' , 'utf-8' ) ; if ( $ component instanceof Component \ VCalendar ) { $ writer -> startElement ( 'icalendar' ) ; $ writer -> writeAt...
Serializes a xCal or xCard object .
39,659
public function getDateTimes ( DateTimeZone $ timeZone = null ) { $ tzid = $ this [ 'TZID' ] ; if ( $ tzid ) { $ timeZone = TimeZoneUtil :: getTimeZone ( ( string ) $ tzid , $ this -> root ) ; } $ dts = [ ] ; foreach ( $ this -> getParts ( ) as $ part ) { $ dts [ ] = DateTimeParser :: parse ( $ part , $ timeZone ) ; } ...
Returns multiple date - time values .
39,660
public function setDateTimes ( array $ dt , $ isFloating = false ) { $ values = [ ] ; if ( $ this -> hasTime ( ) ) { $ tz = null ; $ isUtc = false ; foreach ( $ dt as $ d ) { if ( $ isFloating ) { $ values [ ] = $ d -> format ( 'Ymd\\THis' ) ; continue ; } if ( is_null ( $ tz ) ) { $ tz = $ d -> getTimeZone ( ) ; $ isU...
Sets the property as multiple date - time objects .
39,661
public function getJsonValue ( ) { $ dts = $ this -> getDateTimes ( ) ; $ hasTime = $ this -> hasTime ( ) ; $ isFloating = $ this -> isFloating ( ) ; $ tz = $ dts [ 0 ] -> getTimeZone ( ) ; $ isUtc = $ isFloating ? false : in_array ( $ tz -> getName ( ) , [ 'UTC' , 'GMT' , 'Z' ] ) ; return array_map ( function ( DateTi...
Returns the value in the format it should be encoded for JSON .
39,662
public function offsetSet ( $ name , $ value ) { parent :: offsetSet ( $ name , $ value ) ; if ( 'VALUE' !== strtoupper ( $ name ) ) { return ; } $ this -> setDateTimes ( $ this -> getDateTimes ( ) ) ; }
We need to intercept offsetSet because it may be used to alter the VALUE from DATE - TIME to DATE or vice - versa .
39,663
public function parse ( $ input = null , $ options = 0 ) { if ( ! is_null ( $ input ) ) { $ this -> setInput ( $ input ) ; } if ( is_null ( $ this -> input ) ) { throw new EofException ( 'End of input stream, or no input supplied' ) ; } if ( 0 !== $ options ) { $ this -> options = $ options ; } switch ( $ this -> input...
This method starts the parsing process .
39,664
public function parseComponent ( array $ jComp ) { $ self = $ this ; $ properties = array_map ( function ( $ jProp ) use ( $ self ) { return $ self -> parseProperty ( $ jProp ) ; } , $ jComp [ 1 ] ) ; if ( isset ( $ jComp [ 2 ] ) ) { $ components = array_map ( function ( $ jComp ) use ( $ self ) { return $ self -> pars...
Parses a component .
39,665
public function parseProperty ( array $ jProp ) { list ( $ propertyName , $ parameters , $ valueType ) = $ jProp ; $ propertyName = strtoupper ( $ propertyName ) ; $ defaultPropertyClass = $ this -> root -> getClassNameForPropertyName ( $ propertyName ) ; $ parameters = ( array ) $ parameters ; $ value = array_slice ( ...
Parses properties .
39,666
public static function convertToUTF8 ( $ str ) { $ encoding = mb_detect_encoding ( $ str , [ 'UTF-8' , 'ISO-8859-1' , 'WINDOWS-1252' ] , true ) ; switch ( $ encoding ) { case 'ISO-8859-1' : $ newStr = utf8_encode ( $ str ) ; break ; default : $ newStr = $ str ; } return preg_replace ( '%(?:[\x00-\x08\x0B-\x0C\x0E-\x1F\...
This method tries its best to convert the input string to UTF - 8 .
39,667
public function getNormalizedValue ( ) { $ input = $ this -> getValue ( ) ; if ( ! strpos ( $ input , ':' ) ) { return $ input ; } list ( $ schema , $ everythingElse ) = explode ( ':' , $ input , 2 ) ; return strtolower ( $ schema ) . ':' . $ everythingElse ; }
This returns a normalized form of the value .
39,668
public function getBaseComponents ( $ componentName = null ) { $ isBaseComponent = function ( $ component ) { if ( ! $ component instanceof VObject \ Component ) { return false ; } if ( 'VTIMEZONE' === $ component -> name ) { return false ; } if ( isset ( $ component -> { 'RECURRENCE-ID' } ) ) { return false ; } return...
Returns a list of all base components . For instance if an Event has a recurrence rule and one instance is overridden the overridden event will have the same UID but will be excluded from this list .
39,669
public function expand ( DateTimeInterface $ start , DateTimeInterface $ end , DateTimeZone $ timeZone = null ) { $ newChildren = [ ] ; $ recurringEvents = [ ] ; if ( ! $ timeZone ) { $ timeZone = new DateTimeZone ( 'UTC' ) ; } $ stripTimezones = function ( Component $ component ) use ( $ timeZone , & $ stripTimezones ...
Expand all events in this VCalendar object and return a new VCalendar with the expanded events .
39,670
public function getByUID ( $ uid ) { return array_filter ( $ this -> getComponents ( ) , function ( $ item ) use ( $ uid ) { if ( ! $ itemUid = $ item -> select ( 'UID' ) ) { return false ; } $ itemUid = current ( $ itemUid ) -> getValue ( ) ; return $ uid === $ itemUid ; } ) ; }
Returns all components with a specific UID value .
39,671
public static function stringToArray ( $ value ) { $ value = strtoupper ( $ value ) ; $ newValue = [ ] ; foreach ( explode ( ';' , $ value ) as $ part ) { if ( empty ( $ part ) ) { continue ; } list ( $ partName , $ partValue ) = explode ( '=' , $ part ) ; if ( false !== strpos ( $ partValue , ',' ) ) { $ partValue = e...
Parses an RRULE value string and turns it into a struct - ish array .
39,672
public function create ( $ name ) { if ( isset ( static :: $ componentMap [ strtoupper ( $ name ) ] ) ) { return call_user_func_array ( [ $ this , 'createComponent' ] , func_get_args ( ) ) ; } else { return call_user_func_array ( [ $ this , 'createProperty' ] , func_get_args ( ) ) ; } }
Creates a new component or property .
39,673
public function createProperty ( $ name , $ value = null , array $ parameters = null , $ valueType = null ) { if ( false !== ( $ i = strpos ( $ name , '.' ) ) ) { $ group = substr ( $ name , 0 , $ i ) ; $ name = strtoupper ( substr ( $ name , $ i + 1 ) ) ; } else { $ name = strtoupper ( $ name ) ; $ group = null ; } $ ...
Factory method for creating new properties .
39,674
public function getClassNameForPropertyValue ( $ valueParam ) { $ valueParam = strtoupper ( $ valueParam ) ; if ( isset ( static :: $ valueMap [ $ valueParam ] ) ) { return static :: $ valueMap [ $ valueParam ] ; } }
This method returns a full class - name for a value parameter .
39,675
public function getEffectiveTriggerTime ( ) { $ trigger = $ this -> TRIGGER ; if ( ! isset ( $ trigger [ 'VALUE' ] ) || 'DURATION' === strtoupper ( $ trigger [ 'VALUE' ] ) ) { $ triggerDuration = VObject \ DateTimeParser :: parseDuration ( $ this -> TRIGGER ) ; $ related = ( isset ( $ trigger [ 'RELATED' ] ) && 'END' =...
Returns a DateTime object when this alarm is going to trigger .
39,676
public static function parse ( $ date , $ referenceTz = null ) { if ( 'P' === $ date [ 0 ] || ( '-' === $ date [ 0 ] && 'P' === $ date [ 1 ] ) ) { return self :: parseDuration ( $ date ) ; } elseif ( 8 === strlen ( $ date ) ) { return self :: parseDate ( $ date , $ referenceTz ) ; } else { return self :: parseDateTime ...
Parses either a Date or DateTime or Duration value .
39,677
public function getResult ( ) { $ calendar = new VCalendar ( ) ; foreach ( $ this -> objects as $ object ) { if ( ! $ object -> select ( 'BDAY' ) ) { continue ; } if ( empty ( $ object -> BDAY -> getValue ( ) ) ) { continue ; } $ object = $ object -> convert ( Document :: VCARD40 ) ; if ( ! isset ( $ object -> FN ) ) {...
Parses the input data and returns a VCALENDAR .
39,678
public static function read ( $ data , $ options = 0 , $ charset = 'UTF-8' ) { $ parser = new Parser \ MimeDir ( ) ; $ parser -> setCharset ( $ charset ) ; $ result = $ parser -> parse ( $ data , $ options ) ; return $ result ; }
Parses a vCard or iCalendar object and returns the top component .
39,679
public static function readJson ( $ data , $ options = 0 ) { $ parser = new Parser \ Json ( ) ; $ result = $ parser -> parse ( $ data , $ options ) ; return $ result ; }
Parses a jCard or jCal object and returns the top component .
39,680
public static function readXML ( $ data , $ options = 0 ) { $ parser = new Parser \ XML ( ) ; $ result = $ parser -> parse ( $ data , $ options ) ; return $ result ; }
Parses a xCard or xCal object and returns the top component .
39,681
public function setDateTime ( DateTimeInterface $ dt ) { $ tz = $ dt -> getTimeZone ( ) ; $ isUtc = in_array ( $ tz -> getName ( ) , [ 'UTC' , 'GMT' , 'Z' ] ) ; if ( $ isUtc ) { $ value = $ dt -> format ( 'Ymd\\THis\\Z' ) ; } else { $ value = $ dt -> format ( 'Ymd\\THisO' ) ; } $ this -> value = $ value ; }
Sets the property as a DateTime object .
39,682
public static function initialize ( ) { self :: $ _restClient = new RestClient ( ) ; self :: $ _config = new Config ( null , self :: $ _restClient ) ; self :: $ _restClient -> setHttpParam ( 'address' , self :: $ _config -> get ( 'base_url' ) ) ; self :: $ _manager = new Manager ( self :: $ _restClient , self :: $ _con...
MercadoPagoSdk constructor .
39,683
public static function setAccessToken ( $ access_token ) { if ( ! isset ( self :: $ _config ) ) { self :: initialize ( ) ; } self :: $ _config -> configure ( [ 'ACCESS_TOKEN' => $ access_token ] ) ; }
Set Access Token for SDK .
39,684
public static function setClientId ( $ client_id ) { if ( ! isset ( self :: $ _config ) ) { self :: initialize ( ) ; } self :: $ _config -> configure ( [ 'CLIENT_ID' => $ client_id ] ) ; }
Set Access ClientId for SDK .
39,685
public static function setClientSecret ( $ client_secret ) { if ( ! isset ( self :: $ _config ) ) { self :: initialize ( ) ; } self :: $ _config -> configure ( [ 'CLIENT_SECRET' => $ client_secret ] ) ; }
Set Access ClientSecret for SDK .
39,686
public static function get ( $ uri , $ options = [ ] ) { if ( $ token = self :: $ _config -> get ( 'ACCESS_TOKEN' ) ) { $ uri = $ uri . "?access_token=" . $ token ; } return self :: $ _restClient -> get ( $ uri , $ options ) ; }
Publishing generic functions
39,687
protected function _fillFromArray ( $ entity , $ data ) { if ( $ data ) { foreach ( $ data as $ key => $ value ) { if ( is_array ( $ value ) ) { $ className = 'MercadoPago\\' . $ this -> _camelize ( $ key ) ; if ( class_exists ( $ className , true ) ) { $ entity -> _setValue ( $ key , new $ className , false ) ; $ enti...
Fill entity from data with nested object creation
39,688
public function getToken ( ) { if ( ! $ this -> _restclient ) { $ this -> _restclient = new RestClient ( ) ; } $ data = [ 'grant_type' => 'client_credentials' , 'client_id' => $ this -> get ( 'CLIENT_ID' ) , 'client_secret' => $ this -> get ( 'CLIENT_SECRET' ) ] ; $ this -> _restclient -> setHttpParam ( 'address' , $ t...
Obtain token with key and secret
39,689
protected function encode ( $ value ) { if ( is_array ( $ value ) ) { return array_map ( [ $ this , 'encode' ] , $ value ) ; } else { return str_replace ( [ '+' , '%7E' ] , [ ' ' , '~' ] , rawurlencode ( $ value ) ) ; } }
Encode according to RFC 3986 .
39,690
protected function processFilters ( $ parameters ) { if ( isset ( $ parameters [ 'filter' ] ) ) { $ filters = $ parameters [ 'filter' ] ; unset ( $ parameters [ 'filter' ] ) ; foreach ( $ filters as $ filter => $ value ) { $ parameters [ 'filter[' . $ filter . ']' ] = $ value ; } } return $ parameters ; }
Process filters .
39,691
protected function generateOauthSignature ( $ parameters ) { $ baseRequestUri = \ rawurlencode ( $ this -> url ) ; $ parameters = $ this -> processFilters ( $ parameters ) ; $ parameters = $ this -> normalizeParameters ( $ parameters ) ; \ uksort ( $ parameters , 'strcmp' ) ; $ queryString = \ implode ( '%26' , $ this ...
Generate oAuth1 . 0 signature .
39,692
protected function getSortedParameters ( $ parameters ) { \ uksort ( $ parameters , 'strcmp' ) ; foreach ( $ parameters as $ key => $ value ) { if ( \ is_array ( $ value ) ) { \ uksort ( $ parameters [ $ key ] , 'strcmp' ) ; } } return $ parameters ; }
Sort parameters .
39,693
public function getParameters ( ) { $ parameters = \ array_merge ( $ this -> parameters , [ 'oauth_consumer_key' => $ this -> consumerKey , 'oauth_timestamp' => $ this -> timestamp , 'oauth_nonce' => \ sha1 ( \ microtime ( ) ) , 'oauth_signature_method' => 'HMAC-' . self :: HASH_ALGORITHM , ] ) ; $ parameters [ 'oauth_...
Get oAuth1 . 0 parameters .
39,694
protected function processAuth ( ) { if ( $ this -> doQueryString ) { $ this -> parameters [ 'consumer_key' ] = $ this -> consumerKey ; $ this -> parameters [ 'consumer_secret' ] = $ this -> consumerSecret ; } else { \ curl_setopt ( $ this -> ch , CURLOPT_USERPWD , $ this -> consumerKey . ':' . $ this -> consumerSecret...
Process auth .
39,695
public function getRawHeaders ( ) { $ headers = [ ] ; foreach ( $ this -> headers as $ key => $ value ) { $ headers [ ] = $ key . ': ' . $ value ; } return $ headers ; }
Get raw headers .
39,696
protected function buildApiUrl ( $ url ) { $ api = $ this -> options -> isWPAPI ( ) ? $ this -> options -> apiPrefix ( ) : '/wc-api/' ; return \ rtrim ( $ url , '/' ) . $ api . $ this -> options -> getVersion ( ) . '/' ; }
Build API URL .
39,697
protected function setupMethod ( $ method ) { if ( 'POST' == $ method ) { \ curl_setopt ( $ this -> ch , CURLOPT_POST , true ) ; } elseif ( \ in_array ( $ method , [ 'PUT' , 'DELETE' , 'OPTIONS' ] ) ) { \ curl_setopt ( $ this -> ch , CURLOPT_CUSTOMREQUEST , $ method ) ; } }
Setup method .
39,698
protected function getRequestHeaders ( $ sendData = false ) { $ headers = [ 'Accept' => 'application/json' , 'User-Agent' => $ this -> options -> userAgent ( ) . '/' . Client :: VERSION , ] ; if ( $ sendData ) { $ headers [ 'Content-Type' ] = 'application/json;charset=utf-8' ; } return $ headers ; }
Get request headers .
39,699
protected function getResponseHeaders ( ) { $ headers = [ ] ; $ lines = \ explode ( "\n" , $ this -> responseHeaders ) ; $ lines = \ array_filter ( $ lines , 'trim' ) ; foreach ( $ lines as $ index => $ line ) { if ( strpos ( $ line , ': ' ) === false ) { continue ; } list ( $ key , $ value ) = \ explode ( ': ' , $ lin...
Get response headers .