Skip to content

Commit

Permalink
Tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Aug 22, 2016
1 parent 7adc3ec commit e61ec05
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static public function now()
*/
public function __set($property, $value)
{
if (class_exists('ICanBoogie\PropertyNotWritable'))
if (class_exists(PropertyNotWritable::class))
{
throw new PropertyNotWritable([ $property, $this ]);
}
Expand Down
30 changes: 30 additions & 0 deletions lib/DateTime/Shared.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
use ICanBoogie\DateTime;

/**
* @property-read int $year Year.
* @property-read int $month Month of the year.
* @property-read int $day Day of the month.
* @property-read int $hour Hour of the day.
* @property-read int $minute Minute of the hour.
* @property-read int $second Second of the minute.
*
* @property-read bool $is_empty `true` if the instance represents an empty date such as "0000-00-00" or "0000-00-00 00:00:00".
*
* @property-read string $as_iso8601 The instance formatted according to {@link ISO8601}.
*
* @method string format_as_atom() format_as_atom() Formats the instance according to {@link ATOM}.
* @method string format_as_cookie() format_as_cookie() Formats the instance according to {@link COOKIE}.
* @method string format_as_iso8601() format_as_iso8601() Formats the instance according to {@link ISO8601}.
Expand All @@ -32,6 +43,25 @@
*/
trait Shared
{
/**
* @return int
*/
abstract public function getTimestamp();

/**
* @return \DateTimeZone
*/
abstract public function getTimezone();

/**
* @param int $year
* @param int $month
* @param int $day
*
* @return \DateTime|\DateTimeImmutable
*/
abstract public function setDate($year, $month, $day);

/**
* Creates a {@link DateTime} instance from a source.
*
Expand Down
10 changes: 4 additions & 6 deletions lib/TimeZone.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function __construct($timezone)

if ($name == 'utc')
{
$name = 'UTC';
$name = 'UTC'; // @codeCoverageIgnore
}

$this->name = $name;
Expand Down Expand Up @@ -140,14 +140,12 @@ public function __get($property)
return $this->getOffset($utc_time);
}

if (class_exists('ICanBoogie\PropertyNotDefined'))
if (class_exists(PropertyNotDefined::class))
{
throw new PropertyNotDefined([ $property, $this ]);
}
else
{
throw new \RuntimeException("Property no defined: $property.");
}

throw new \RuntimeException("Property no defined: $property."); // @codeCoverageIgnore
}

/**
Expand Down
10 changes: 4 additions & 6 deletions lib/TimeZoneLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function __get($property)
return $this->location[$property];
}

if (class_exists('ICanBoogie\PropertyNotDefined'))
if (class_exists(PropertyNotDefined::class))
{
throw new PropertyNotDefined([ $property, $this ]);
}
Expand All @@ -102,14 +102,12 @@ public function __get($property)
*/
public function __set($property, $value)
{
if (class_exists('ICanBoogie\PropertyNotWritable'))
if (class_exists(PropertyNotWritable::class))
{
throw new PropertyNotWritable([ $property, $this ]);
}
else
{
throw new \RuntimeException("Property is not writable: $property.");
}

throw new \RuntimeException("Property is not writable: $property."); // @codeCoverageIgnore
}

/**
Expand Down

0 comments on commit e61ec05

Please sign in to comment.