Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
markuspoerschke committed Jul 6, 2014
1 parent 79ec8b7 commit db02a89
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/Eluceo/iCal/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ public function build()

$lines[] = sprintf('BEGIN:%s', $this->getType());

/** @var $property Property */
foreach ($this->properties as $property) {
$lines[] = $property->toLine();
}

/** @var $component Component */
foreach ($this->components as $component) {
foreach ($component->build() as $l) {
$lines[] = $l;
Expand Down
13 changes: 13 additions & 0 deletions src/Eluceo/iCal/Component/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,34 @@ public function getType()
return 'VCALENDAR';
}

/**
* @param $method
* @return $this
*/
public function setMethod($method)
{
$this->method = $method;
return $this;
}

/**
* @param $name
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this;
}

/**
* @param $timezone
* @return $this
*/
public function setTimezone($timezone)
{
$this->timezone = $timezone;

return $this;
}

Expand Down
80 changes: 74 additions & 6 deletions src/Eluceo/iCal/Component/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
*/
class Event extends Component
{

const TIME_TRANSPARENCY_OPAQUE = 'OPAQUE';
const TIME_TRANSPARENCY_OPAQUE = 'OPAQUE';
const TIME_TRANSPARENCY_TRANSPARENT = 'TRANSPARENT';

const STATUS_TENTATIVE = 'TENTATIVE';
const STATUS_CONFIRMED = 'CONFIRMED';
const STATUS_CANCELLED = 'CANCELLED';
Expand Down Expand Up @@ -210,8 +210,9 @@ public function buildPropertyBag()
$this->properties->set('RRULE', $this->recurrenceRule);
}

if( $this->noTime )
if( $this->noTime ) {
$this->properties->set('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE');
}
}

/**
Expand All @@ -232,8 +233,9 @@ protected function buildDateTimeProperty($name, \DateTime $dateTime, $noTime = f
$params['TZID'] = $timeZone;
}

if( $noTime )
if($noTime) {
$params['VALUE'] = 'DATE';
}

return new Property($name, $dateString, $params);
}
Expand Down Expand Up @@ -270,30 +272,52 @@ protected function getDateString(\DateTime $dateTime = null, $noTime = false)
return $dateTime->format($this->getDateFormat($noTime));
}

/**
* @param $dtEnd
* @return $this
*/
public function setDtEnd($dtEnd)
{
$this->dtEnd = $dtEnd;
return $this;
}

/**
* @param $dtStart
* @return $this
*/
public function setDtStart($dtStart)
{
$this->dtStart = $dtStart;
return $this;
}

/**
* @param $dtStamp
* @return $this
*/
public function setDtStamp($dtStamp)
{
$this->dtStamp = $dtStamp;
return $this;
}

/**
* @param $duration
* @return $this
*/
public function setDuration($duration)
{
$this->duration = $duration;
return $this;
}

/**
* @param $location
* @param string $title
* @param null $geo
* @return $this
*/
public function setLocation($location, $title = '', $geo = null)
{
$this->location = $location;
Expand All @@ -302,49 +326,77 @@ public function setLocation($location, $title = '', $geo = null)
return $this;
}

/**
* @param $noTime
* @return $this
*/
public function setNoTime($noTime)
{
$this->noTime = $noTime;
return $this;
}

/**
* @param $sequence
* @return $this
*/
public function setSequence($sequence)
{
$this->sequence = $sequence;
return $this;
}

/**
* @param $summary
* @return $this
*/
public function setSummary($summary)
{
$this->summary = $summary;
return $this;
}

/**
* @param $uniqueId
* @return $this
*/
public function setUniqueId($uniqueId)
{
$this->uniqueId = $uniqueId;
return $this;
}

/**
* @param $url
* @return $this
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}

/**
* @param $useTimezone
* @return $this
*/
public function setUseTimezone($useTimezone)
{
$this->useTimezone = $useTimezone;
return $this;
}

/**
* @return bool
*/
public function getUseTimezone()
{
return $this->useTimezone;
}

/**
* @param string $description
* @param $attendee
* @return $this
*/
public function setAttendee($attendee)
{
Expand All @@ -361,14 +413,19 @@ public function getAttendee()
}

/**
* @param string $description
* @param $description
* @return $this
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}

/**
* @param bool $useUtc
* @return $this
*/
public function setUseUtc($useUtc = true)
{
$this->useUtc = $useUtc;
Expand All @@ -383,6 +440,11 @@ public function getDescription()
return $this->description;
}

/**
* @param $transparency
* @return $this
* @throws \InvalidArgumentException
*/
public function setTimeTransparency($transparency)
{
$transparency = strtoupper($transparency);
Expand All @@ -395,6 +457,11 @@ public function setTimeTransparency($transparency)
return $this;
}

/**
* @param $status
* @return $this
* @throws \InvalidArgumentException
*/
public function setStatus($status)
{
$status = strtoupper($status);
Expand All @@ -410,6 +477,7 @@ public function setStatus($status)

/**
* @param RecurrenceRule $recurrenceRule
* @return $this
*/
public function setRecurrenceRule(RecurrenceRule $recurrenceRule)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Eluceo/iCal/ParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class ParameterBag
*/
protected $params;

public function __construct($parms = array())
public function __construct($params = array())
{
$this->params = $parms;
$this->params = $params;
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/Eluceo/iCal/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ public function toLine()

/**
* @param string $name
* @param mixed $value
* @param mixed $value
*
* @return $this
*/
public function setParam($name, $value)
{
$this->parameterBag->setParam($name, $value);

return $this;
}

Expand All @@ -95,6 +98,7 @@ public function getParam($name)

/**
* @param mixed $value
* @return $this
* @throws \Exception
*/
public function setValue($value)
Expand All @@ -106,6 +110,7 @@ public function setValue($value)
} else {
$this->value = $value;
}

return $this;
}

Expand Down
7 changes: 6 additions & 1 deletion src/Eluceo/iCal/PropertyBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ class PropertyBag implements \IteratorAggregate
* @param $name
* @param $value
* @param array $params
* @return $this
*/
public function set($name, $value, $params = array())
{
$property = new Property($name, $value, $params);
$this->elements[] = $property;

return $this;
}

Expand All @@ -41,6 +43,7 @@ public function set($name, $value, $params = array())
public function get($name)
{
// Searching Property in elements-array
/** @var $property Property */
foreach ($this->elements as $property) {
if ($property->getName() == $name) {
return $property;
Expand All @@ -53,7 +56,8 @@ public function get($name)
/**
* Adds a Property. If Property already exists an Exception will be thrown.
*
* @param Property $property
* @param Property $property
* @return $this
* @throws \Exception
*/
public function add(Property $property)
Expand All @@ -64,6 +68,7 @@ public function add(Property $property)
}

$this->elements[] = $property;

return $this;
}

Expand Down

0 comments on commit db02a89

Please sign in to comment.