Skip to content

Commit f6cd431

Browse files
QuentinGabgithub-actions[bot]
authored andcommitted
Fix styling
1 parent 367a6d2 commit f6cd431

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

src/GenerateSerialNumber.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
namespace Finller\Invoice;
44

5-
use Carbon\Carbon;
6-
75
interface GenerateSerialNumber
86
{
97
public function __construct(string $format = null, string $prefix = null);
108

119
public function generate(
1210
int $count,
1311
int $serie = null,
14-
string|int|null $year = null,
15-
string|int|null $month = null
12+
string|int $year = null,
13+
string|int $month = null
1614
): string;
1715

1816
public function parse(string $serialNumber): array;

src/Invoice.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,46 +147,52 @@ public function getLatestSerialNumber(): ?string
147147
return $latestInvoice?->serial_number;
148148
}
149149

150-
function initSerialNumberDetailst(): static
150+
public function initSerialNumberDetailst(): static
151151
{
152-
if (!$this->serial_number_details) {
152+
if (! $this->serial_number_details) {
153153
$this->serial_number_details = new ArrayObject();
154154
}
155+
155156
return $this;
156157
}
157158

158159
public function setSerialNumberPrefix(string $value): static
159160
{
160161
$this->initSerialNumberDetailst();
161162
$this->serial_number_details['prefix'] = $value;
163+
162164
return $this;
163165
}
164166

165167
public function setSerialNumberSerie(int $value): static
166168
{
167169
$this->initSerialNumberDetailst();
168170
$this->serial_number_details['serie'] = $value;
171+
169172
return $this;
170173
}
171174

172175
public function setSerialNumberYear(int $value): static
173176
{
174177
$this->initSerialNumberDetailst();
175178
$this->serial_number_details['year'] = $value;
179+
176180
return $this;
177181
}
178182

179183
public function setSerialNumberMonth(int $value): static
180184
{
181185
$this->initSerialNumberDetailst();
182186
$this->serial_number_details['month'] = $value;
187+
183188
return $this;
184189
}
185190

186191
public function setSerialNumberCount(int $value): static
187192
{
188193
$this->initSerialNumberDetailst();
189194
$this->serial_number_details['count'] = $value;
195+
190196
return $this;
191197
}
192198

@@ -195,6 +201,7 @@ public function setSerialNumberDate(Carbon $value): static
195201
$this->initSerialNumberDetailst();
196202
$this->serial_number_details['year'] = (int) $value->format('Y');
197203
$this->serial_number_details['month'] = (int) $value->format('m');
204+
198205
return $this;
199206
}
200207

src/InvoiceItem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class InvoiceItem extends Model
3636
/**
3737
* This cast will be forwarded to the class defined in config at invoices.money_cast
3838
*/
39-
'unit_price' => MoneyCast::class . ':currency',
40-
'unit_tax' => MoneyCast::class . ':currency',
39+
'unit_price' => MoneyCast::class.':currency',
40+
'unit_tax' => MoneyCast::class.':currency',
4141
'metadata' => AsArrayObject::class,
4242
'tax_percentage' => 'float',
4343
];

src/SerialNumberGenerator.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Finller\Invoice;
44

5-
use Carbon\Carbon;
6-
75
class SerialNumberGenerator implements GenerateSerialNumber
86
{
97
public function __construct(
@@ -17,17 +15,17 @@ public function __construct(
1715
public function generate(
1816
int $count,
1917
int $serie = null,
20-
string|int|null $year = null,
21-
string|int|null $month = null,
18+
string|int $year = null,
19+
string|int $month = null,
2220
): string {
2321
return preg_replace_callback_array(
2422
[
2523
'/S+/' => function ($matches) use ($serie) {
26-
if (!$matches[0]) {
24+
if (! $matches[0]) {
2725
return '';
2826
}
2927
$slotLength = strlen($matches[0]);
30-
throw_if(!$serie, "The serial Number format includes a $slotLength long Serie (S), but no serie has been passed");
28+
throw_if(! $serie, "The serial Number format includes a $slotLength long Serie (S), but no serie has been passed");
3129

3230
$serieLength = strlen(strval($serie));
3331
throw_if(
@@ -45,7 +43,7 @@ public function generate(
4543
'/M+/' => fn ($matches) => $matches[0] && $month ? substr((string) $month, -strlen($matches[0])) : '',
4644
'/Y+/' => fn ($matches) => $matches[0] && $year ? substr((string) $year, -strlen($matches[0])) : '',
4745
'/C+/' => function ($matches) use ($count) {
48-
if (!$matches[0]) {
46+
if (! $matches[0]) {
4947
return '';
5048
}
5149
throw_if(
@@ -62,7 +60,7 @@ public function generate(
6260
},
6361
// Must be kept last to avoid interfering with other callbacks
6462
'/P+/' => function ($matches) {
65-
if (!$matches[0]) {
63+
if (! $matches[0]) {
6664
return '';
6765
}
6866
$slotLength = strlen($matches[0]);

tests/Unit/SerialNumberTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
prefix: $prefix
99
);
1010

11-
$serialNumber = $generator->generate(count: $count, serie: $serie, year: "2022", month: '01');
11+
$serialNumber = $generator->generate(count: $count, serie: $serie, year: '2022', month: '01');
1212

1313
expect($serialNumber)->toBe($expected);
1414
})->with([

0 commit comments

Comments
 (0)