Skip to content

Commit

Permalink
Using AccessorTrait
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Dec 20, 2014
1 parent 15e7554 commit e316eff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
28 changes: 3 additions & 25 deletions lib/LocalizedObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace ICanBoogie\CLDR;

use ICanBoogie\PropertyNotDefined;

/**
* Representation of a localized object.
*
Expand All @@ -36,6 +34,9 @@ static public function from($source, Locale $locale, array $options=[])
return new static($source, $locale, $options);
}

use AccessorTrait;
use LocalePropertyTrait;

/**
* The object to localize.
*
Expand All @@ -48,8 +49,6 @@ protected function get_target()
return $this->target;
}

use LocalePropertyTrait;

/**
* Options.
*
Expand All @@ -70,25 +69,4 @@ public function __construct($target, Locale $locale, array $options=[])
$this->locale = $locale;
$this->options = $options;
}

/**
* Support for the {@link $target}, {@link $locale}, and {@link $formatter} properties.
*
* @param string $property
*
* @throws PropertyNotDefined in attempt to get a property that is not supported.
*
* @return mixed
*/
public function __get($property)
{
$method = 'get_' . $property;

if (method_exists($this, $method))
{
return $this->$method();
}

throw new PropertyNotDefined([ $property, $this ]);
}
}
2 changes: 1 addition & 1 deletion tests/LocalizedDateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function test_get_locale()
}

/**
* @expectedException \ICanBoogie\PropertyNotDefined
* @expectedException \ICanBoogie\PropertyNotReadable
*/
public function test_get_options()
{
Expand Down

0 comments on commit e316eff

Please sign in to comment.