Skip to content

Commit 00542b2

Browse files
committed
private => protected
1 parent 6f67fe5 commit 00542b2

21 files changed

Lines changed: 99 additions & 98 deletions

src/Geo/Country.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,17 @@ class Country
267267
/**
268268
* @var string
269269
*/
270-
private $isoCode;
270+
protected $isoCode;
271271

272272
/**
273273
* @var string
274274
*/
275-
private $name;
275+
protected $name;
276276

277277
/**
278278
* @param string $isoCode
279279
*/
280-
private function __construct(string $isoCode, string $name)
280+
protected function __construct(string $isoCode, string $name)
281281
{
282282
$this->isoCode = $isoCode;
283283
$this->name = $name;
@@ -296,7 +296,7 @@ public static function __callStatic(string $name, array $arguments)
296296
throw new InvalidArgumentException(sprintf('Invalid country code: %s', $isoCode));
297297
}
298298

299-
return new self($isoCode, $name);
299+
return new static($isoCode, $name);
300300
}
301301

302302
/**

src/Geo/Japan/Prefecture.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,27 @@ class Prefecture
112112
/**
113113
* @var string
114114
*/
115-
private $isoCode;
115+
protected $isoCode;
116116

117117
/**
118118
* @var string
119119
*/
120-
private $name;
120+
protected $name;
121121

122122
/**
123123
* @var string
124124
*/
125-
private $kanjiName;
125+
protected $kanjiName;
126126

127127
/**
128128
* @var PrefectureSuffix
129129
*/
130-
private $suffix;
130+
protected $suffix;
131131

132132
/**
133133
* @var Region
134134
*/
135-
private $region;
135+
protected $region;
136136

137137
/**
138138
* @param string $isoCode
@@ -141,7 +141,7 @@ class Prefecture
141141
* @param PrefectureSuffix $suffix
142142
* @param Region $region
143143
*/
144-
private function __construct(
144+
protected function __construct(
145145
string $isoCode,
146146
string $name,
147147
string $kanjiName,
@@ -172,7 +172,7 @@ public static function __callStatic(string $name, array $arguments): self
172172
$suffixFactoryMethod = $datum['suffix'];
173173
$regionFactoryMethod = $datum['region'];
174174

175-
return new self(
175+
return new static(
176176
$datum['isoCode'],
177177
$datum['name'],
178178
$datum['kanjiName'],
@@ -197,7 +197,7 @@ public static function ofKanjiName(string $kanjiName): self
197197
$suffixFactoryMethod = $datum['suffix'];
198198
$regionFactoryMethod = $datum['region'];
199199

200-
return new self (
200+
return new static(
201201
$datum['isoCode'],
202202
$datum['name'],
203203
$datum['kanjiName'],
@@ -229,7 +229,7 @@ public static function ofSuffixedKanjiName(string $suffixedKanjiName): self
229229
$suffixFactoryMethod = $datum['suffix'];
230230
$regionFactoryMethod = $datum['region'];
231231

232-
return new self (
232+
return new static(
233233
$datum['isoCode'],
234234
$datum['name'],
235235
$datum['kanjiName'],

src/Geo/Japan/PrefectureSuffix.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ class PrefectureSuffix
2525
/**
2626
* @var string
2727
*/
28-
private $name;
28+
protected $name;
2929

3030
/**
3131
* @var string
3232
*/
33-
private $kanjiName;
33+
protected $kanjiName;
3434

3535
/**
3636
* @param string $name
3737
* @param string $kanjiName
3838
*/
39-
private function __construct(string $name, string $kanjiName)
39+
protected function __construct(string $name, string $kanjiName)
4040
{
4141
$this->name = $name;
4242
$this->kanjiName = $kanjiName;
@@ -57,7 +57,7 @@ public static function __callStatic(string $name, array $arguments): self
5757
}
5858
$datum = array_shift($filteredData);
5959

60-
return new self($datum['name'], $datum['kanjiName']);
60+
return new static($datum['name'], $datum['kanjiName']);
6161
}
6262

6363
/**

src/Geo/Japan/Region.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,18 @@ class Region
3737
/**
3838
* @var string
3939
*/
40-
private $name;
40+
protected $name;
4141

4242
/**
4343
* @var string
4444
*/
45-
private $kanjiName;
45+
protected $kanjiName;
4646

4747
/**
48-
* @param array $region
48+
* @param string $name
49+
* @param string $kanjiName
4950
*/
50-
private function __construct(string $name, string $kanjiName)
51+
protected function __construct(string $name, string $kanjiName)
5152
{
5253
$this->name = $name;
5354
$this->kanjiName = $kanjiName;
@@ -81,7 +82,7 @@ public static function fromName(string $name): self
8182
new InvalidArgumentException(sprintf('Invalid region name: %s', $name))
8283
);
8384

84-
return new self($datum['name'], $datum['kanjiName']);
85+
return new static($datum['name'], $datum['kanjiName']);
8586
}
8687

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

99-
return new self($datum['name'], $datum['kanjiName']);
100+
return new static($datum['name'], $datum['kanjiName']);
100101
}
101102

102103
/**
@@ -131,7 +132,7 @@ public function equals(self $other): bool
131132
* @return array
132133
* @throws Exception
133134
*/
134-
private static function filterData(string $key, string $value, Exception $e): array
135+
protected static function filterData(string $key, string $value, Exception $e): array
135136
{
136137
$filteredData = array_filter(self::DATA, function (array $datum) use ($key, $value) {
137138
return $value === $datum[$key];
@@ -147,8 +148,8 @@ private static function filterData(string $key, string $value, Exception $e): ar
147148
* @param array $datum
148149
* @return self
149150
*/
150-
private static function createInstance(array $datum): self
151+
protected static function createInstance(array $datum): self
151152
{
152-
return new self($datum['name'], $datum['kanjiName']);
153+
return new static($datum['name'], $datum['kanjiName']);
153154
}
154155
}

src/Geo/Latitude.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Latitude
99
/**
1010
* @var float
1111
*/
12-
private $latitude;
12+
protected $latitude;
1313

1414
/**
1515
* @param float $latitude

src/Geo/Longitude.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Longitude
99
/**
1010
* @var float
1111
*/
12-
private $longitude;
12+
protected $longitude;
1313

1414
/**
1515
* @param float $longitude

src/Geo/Position.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ class Position
77
/**
88
* @var Latitude
99
*/
10-
private $latitude;
10+
protected $latitude;
1111

1212
/**
1313
* @var Longitude
1414
*/
15-
private $longitude;
15+
protected $longitude;
1616

1717
/**
1818
* @param Latitude $latitude

src/Money/Currency.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,17 @@ class Currency
179179
/**
180180
* @var string
181181
*/
182-
private $isoCode;
182+
protected $isoCode;
183183

184184
/**
185185
* @var int
186186
*/
187-
private $decimalPlaces;
187+
protected $decimalPlaces;
188188

189189
/**
190190
* @param string $isoCode
191191
*/
192-
private function __construct(string $isoCode)
192+
protected function __construct(string $isoCode)
193193
{
194194
$this->isoCode = $isoCode;
195195
if (in_array($isoCode, ['BHD', 'IQD', 'JOD', 'KWD', 'LYD', 'OMR', 'TND'])) {
@@ -210,17 +210,17 @@ private function __construct(string $isoCode)
210210
/**
211211
* @param string $name
212212
* @param array $arguments
213-
* @return self
213+
* @return Currency
214214
*/
215-
public static function __callStatic(string $name, array $arguments)
215+
public static function __callStatic(string $name, array $arguments): Currency
216216
{
217217
$isoCode = strtoupper($name);
218218
$name = Intl::getCurrencyBundle()->getCurrencyName($isoCode);
219219
if (null === $name) {
220220
throw new InvalidArgumentException(sprintf('Invalid currency code: %s', $isoCode));
221221
}
222222

223-
return new self($isoCode);
223+
return new static($isoCode);
224224
}
225225

226226
/**

src/Money/Money.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ class Money
99
/**
1010
* @var int
1111
*/
12-
private $amount;
12+
protected $amount;
1313

1414
/**
1515
* @var Currency
1616
*/
17-
private $currency;
17+
protected $currency;
1818

1919
/**
2020
* @param int $amount
@@ -52,18 +52,18 @@ public function equals(self $other): bool
5252
}
5353

5454
/**
55-
* @return self
55+
* @return Money
5656
*/
57-
public function duplicate(): self
57+
public function duplicate()
5858
{
59-
return new self($this->amount(), $this->currency());
59+
return new static($this->amount(), $this->currency());
6060
}
6161

6262
/**
6363
* @param self $other
64-
* @return self
64+
* @return Money
6565
*/
66-
public function add(self $other): self
66+
public function add(self $other): Money
6767
{
6868
if (!$this->currency()->equals($other->currency())) {
6969
throw new InvalidArgumentException(
@@ -75,7 +75,7 @@ public function add(self $other): self
7575
);
7676
}
7777

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

8181
/**
@@ -94,7 +94,7 @@ public function sub(self $other): self
9494
);
9595
}
9696

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

100100
/**
@@ -103,7 +103,7 @@ public function sub(self $other): self
103103
*/
104104
public function multiply(float $multiplier): self
105105
{
106-
return new self(intval(floor($this->amount() * $multiplier)), $this->currency());
106+
return new static(intval(floor($this->amount() * $multiplier)), $this->currency());
107107
}
108108

109109
/**
@@ -121,7 +121,7 @@ public function increaseAmountBy(int $amount): self
121121
);
122122
}
123123

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

127127
/**
@@ -139,6 +139,6 @@ public function decreaseAmountBy(int $amount): self
139139
);
140140
}
141141

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

src/Time/Date.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ class Date
1212
/**
1313
* @var int
1414
*/
15-
private $year;
15+
protected $year;
1616

1717
/**
1818
* @var int
1919
*/
20-
private $month;
20+
protected $month;
2121

2222
/**
2323
* @var int
2424
*/
25-
private $day;
25+
protected $day;
2626

2727
/**
2828
* @param int $year

0 commit comments

Comments
 (0)