Skip to content

Commit

Permalink
private => protected
Browse files Browse the repository at this point in the history
  • Loading branch information
tanigami committed Jan 29, 2019
1 parent 6f67fe5 commit 00542b2
Show file tree
Hide file tree
Showing 21 changed files with 99 additions and 98 deletions.
8 changes: 4 additions & 4 deletions src/Geo/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,17 @@ class Country
/**
* @var string
*/
private $isoCode;
protected $isoCode;

/**
* @var string
*/
private $name;
protected $name;

/**
* @param string $isoCode
*/
private function __construct(string $isoCode, string $name)
protected function __construct(string $isoCode, string $name)
{
$this->isoCode = $isoCode;
$this->name = $name;
Expand All @@ -296,7 +296,7 @@ public static function __callStatic(string $name, array $arguments)
throw new InvalidArgumentException(sprintf('Invalid country code: %s', $isoCode));
}

return new self($isoCode, $name);
return new static($isoCode, $name);
}

/**
Expand Down
18 changes: 9 additions & 9 deletions src/Geo/Japan/Prefecture.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,27 @@ class Prefecture
/**
* @var string
*/
private $isoCode;
protected $isoCode;

/**
* @var string
*/
private $name;
protected $name;

/**
* @var string
*/
private $kanjiName;
protected $kanjiName;

/**
* @var PrefectureSuffix
*/
private $suffix;
protected $suffix;

/**
* @var Region
*/
private $region;
protected $region;

/**
* @param string $isoCode
Expand All @@ -141,7 +141,7 @@ class Prefecture
* @param PrefectureSuffix $suffix
* @param Region $region
*/
private function __construct(
protected function __construct(
string $isoCode,
string $name,
string $kanjiName,
Expand Down Expand Up @@ -172,7 +172,7 @@ public static function __callStatic(string $name, array $arguments): self
$suffixFactoryMethod = $datum['suffix'];
$regionFactoryMethod = $datum['region'];

return new self(
return new static(
$datum['isoCode'],
$datum['name'],
$datum['kanjiName'],
Expand All @@ -197,7 +197,7 @@ public static function ofKanjiName(string $kanjiName): self
$suffixFactoryMethod = $datum['suffix'];
$regionFactoryMethod = $datum['region'];

return new self (
return new static(
$datum['isoCode'],
$datum['name'],
$datum['kanjiName'],
Expand Down Expand Up @@ -229,7 +229,7 @@ public static function ofSuffixedKanjiName(string $suffixedKanjiName): self
$suffixFactoryMethod = $datum['suffix'];
$regionFactoryMethod = $datum['region'];

return new self (
return new static(
$datum['isoCode'],
$datum['name'],
$datum['kanjiName'],
Expand Down
8 changes: 4 additions & 4 deletions src/Geo/Japan/PrefectureSuffix.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ class PrefectureSuffix
/**
* @var string
*/
private $name;
protected $name;

/**
* @var string
*/
private $kanjiName;
protected $kanjiName;

/**
* @param string $name
* @param string $kanjiName
*/
private function __construct(string $name, string $kanjiName)
protected function __construct(string $name, string $kanjiName)
{
$this->name = $name;
$this->kanjiName = $kanjiName;
Expand All @@ -57,7 +57,7 @@ public static function __callStatic(string $name, array $arguments): self
}
$datum = array_shift($filteredData);

return new self($datum['name'], $datum['kanjiName']);
return new static($datum['name'], $datum['kanjiName']);
}

/**
Expand Down
19 changes: 10 additions & 9 deletions src/Geo/Japan/Region.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ class Region
/**
* @var string
*/
private $name;
protected $name;

/**
* @var string
*/
private $kanjiName;
protected $kanjiName;

/**
* @param array $region
* @param string $name
* @param string $kanjiName
*/
private function __construct(string $name, string $kanjiName)
protected function __construct(string $name, string $kanjiName)
{
$this->name = $name;
$this->kanjiName = $kanjiName;
Expand Down Expand Up @@ -81,7 +82,7 @@ public static function fromName(string $name): self
new InvalidArgumentException(sprintf('Invalid region name: %s', $name))
);

return new self($datum['name'], $datum['kanjiName']);
return new static($datum['name'], $datum['kanjiName']);
}

/**
Expand All @@ -96,7 +97,7 @@ public static function fromKanjiName(string $kanjiName): self
new InvalidArgumentException(sprintf('Invalid region name in kanji: %s', $kanjiName))
);

return new self($datum['name'], $datum['kanjiName']);
return new static($datum['name'], $datum['kanjiName']);
}

/**
Expand Down Expand Up @@ -131,7 +132,7 @@ public function equals(self $other): bool
* @return array
* @throws Exception
*/
private static function filterData(string $key, string $value, Exception $e): array
protected static function filterData(string $key, string $value, Exception $e): array
{
$filteredData = array_filter(self::DATA, function (array $datum) use ($key, $value) {
return $value === $datum[$key];
Expand All @@ -147,8 +148,8 @@ private static function filterData(string $key, string $value, Exception $e): ar
* @param array $datum
* @return self
*/
private static function createInstance(array $datum): self
protected static function createInstance(array $datum): self
{
return new self($datum['name'], $datum['kanjiName']);
return new static($datum['name'], $datum['kanjiName']);
}
}
2 changes: 1 addition & 1 deletion src/Geo/Latitude.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Latitude
/**
* @var float
*/
private $latitude;
protected $latitude;

/**
* @param float $latitude
Expand Down
2 changes: 1 addition & 1 deletion src/Geo/Longitude.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Longitude
/**
* @var float
*/
private $longitude;
protected $longitude;

/**
* @param float $longitude
Expand Down
4 changes: 2 additions & 2 deletions src/Geo/Position.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ class Position
/**
* @var Latitude
*/
private $latitude;
protected $latitude;

/**
* @var Longitude
*/
private $longitude;
protected $longitude;

/**
* @param Latitude $latitude
Expand Down
12 changes: 6 additions & 6 deletions src/Money/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,17 @@ class Currency
/**
* @var string
*/
private $isoCode;
protected $isoCode;

/**
* @var int
*/
private $decimalPlaces;
protected $decimalPlaces;

/**
* @param string $isoCode
*/
private function __construct(string $isoCode)
protected function __construct(string $isoCode)
{
$this->isoCode = $isoCode;
if (in_array($isoCode, ['BHD', 'IQD', 'JOD', 'KWD', 'LYD', 'OMR', 'TND'])) {
Expand All @@ -210,17 +210,17 @@ private function __construct(string $isoCode)
/**
* @param string $name
* @param array $arguments
* @return self
* @return Currency
*/
public static function __callStatic(string $name, array $arguments)
public static function __callStatic(string $name, array $arguments): Currency
{
$isoCode = strtoupper($name);
$name = Intl::getCurrencyBundle()->getCurrencyName($isoCode);
if (null === $name) {
throw new InvalidArgumentException(sprintf('Invalid currency code: %s', $isoCode));
}

return new self($isoCode);
return new static($isoCode);
}

/**
Expand Down
24 changes: 12 additions & 12 deletions src/Money/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class Money
/**
* @var int
*/
private $amount;
protected $amount;

/**
* @var Currency
*/
private $currency;
protected $currency;

/**
* @param int $amount
Expand Down Expand Up @@ -52,18 +52,18 @@ public function equals(self $other): bool
}

/**
* @return self
* @return Money
*/
public function duplicate(): self
public function duplicate()
{
return new self($this->amount(), $this->currency());
return new static($this->amount(), $this->currency());
}

/**
* @param self $other
* @return self
* @return Money
*/
public function add(self $other): self
public function add(self $other): Money
{
if (!$this->currency()->equals($other->currency())) {
throw new InvalidArgumentException(
Expand All @@ -75,7 +75,7 @@ public function add(self $other): self
);
}

return new self($this->amount() + $other->amount(), $this->currency());
return new static($this->amount() + $other->amount(), $this->currency());
}

/**
Expand All @@ -94,7 +94,7 @@ public function sub(self $other): self
);
}

return new self($this->amount() - $other->amount(), $this->currency());
return new static($this->amount() - $other->amount(), $this->currency());
}

/**
Expand All @@ -103,7 +103,7 @@ public function sub(self $other): self
*/
public function multiply(float $multiplier): self
{
return new self(intval(floor($this->amount() * $multiplier)), $this->currency());
return new static(intval(floor($this->amount() * $multiplier)), $this->currency());
}

/**
Expand All @@ -121,7 +121,7 @@ public function increaseAmountBy(int $amount): self
);
}

return new self($this->amount() + $amount, $this->currency());
return new static($this->amount() + $amount, $this->currency());
}

/**
Expand All @@ -139,6 +139,6 @@ public function decreaseAmountBy(int $amount): self
);
}

return new self($this->amount() - $amount, $this->currency());
return new static($this->amount() - $amount, $this->currency());
}
}
6 changes: 3 additions & 3 deletions src/Time/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ class Date
/**
* @var int
*/
private $year;
protected $year;

/**
* @var int
*/
private $month;
protected $month;

/**
* @var int
*/
private $day;
protected $day;

/**
* @param int $year
Expand Down
Loading

0 comments on commit 00542b2

Please sign in to comment.