Skip to content

Commit 346d995

Browse files
committed
~cleanup
1 parent dbe548c commit 346d995

18 files changed

+175
-126
lines changed

.tools/.report/.build/coverage.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
Code Coverage Report Summary:
4-
Classes: 100.00% (213/213)
5-
Methods: 100.00% (770/770)
6-
Lines: 100.00% (3834/3834)
4+
Classes: 100.00% (214/214)
5+
Methods: 100.00% (775/775)
6+
Lines: 100.00% (3856/3856)
77

.tools/.report/.phploc/.src.phploc.report

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
phploc 7.0.2 by Sebastian Bergmann.
22

33
Directories 77
4-
Files 427
4+
Files 429
55

66
Size
7-
Lines of Code (LOC) 14121
8-
Comment Lines of Code (CLOC) 802 (5.68%)
9-
Non-Comment Lines of Code (NCLOC) 13319 (94.32%)
10-
Logical Lines of Code (LLOC) 1504 (10.65%)
11-
Classes 1403 (93.28%)
7+
Lines of Code (LOC) 14201
8+
Comment Lines of Code (CLOC) 802 (5.65%)
9+
Non-Comment Lines of Code (NCLOC) 13399 (94.35%)
10+
Logical Lines of Code (LLOC) 1523 (10.72%)
11+
Classes 1422 (93.37%)
1212
Average Class Length 3
1313
Minimum Class Length 0
1414
Maximum Class Length 27
@@ -18,12 +18,12 @@ Size
1818
Average Methods Per Class 2
1919
Minimum Methods Per Class 0
2020
Maximum Methods Per Class 12
21-
Functions 38 (2.53%)
21+
Functions 38 (2.50%)
2222
Average Function Length 1
23-
Not in classes or functions 63 (4.19%)
23+
Not in classes or functions 63 (4.14%)
2424

2525
Cyclomatic Complexity
26-
Average Complexity per LLOC 0.34
26+
Average Complexity per LLOC 0.33
2727
Average Complexity per Class 2.11
2828
Minimum Class Complexity 1.00
2929
Maximum Class Complexity 21.00
@@ -36,30 +36,30 @@ Dependencies
3636
Global Constants 0 (0.00%)
3737
Global Variables 0 (0.00%)
3838
Super-Global Variables 0 (0.00%)
39-
Attribute Accesses 659
40-
Non-Static 643 (97.57%)
41-
Static 16 (2.43%)
42-
Method Calls 824
43-
Non-Static 742 (90.05%)
44-
Static 82 (9.95%)
39+
Attribute Accesses 670
40+
Non-Static 654 (97.61%)
41+
Static 16 (2.39%)
42+
Method Calls 829
43+
Non-Static 747 (90.11%)
44+
Static 82 (9.89%)
4545

4646
Structure
4747
Namespaces 77
48-
Interfaces 196
48+
Interfaces 197
4949
Traits 0
50-
Classes 210
51-
Abstract Classes 14 (6.67%)
52-
Concrete Classes 196 (93.33%)
53-
Final Classes 73 (37.24%)
54-
Non-Final Classes 123 (62.76%)
55-
Methods 1012
50+
Classes 211
51+
Abstract Classes 14 (6.64%)
52+
Concrete Classes 197 (93.36%)
53+
Final Classes 74 (37.56%)
54+
Non-Final Classes 123 (62.44%)
55+
Methods 1021
5656
Scope
57-
Non-Static Methods 947 (93.58%)
58-
Static Methods 65 (6.42%)
57+
Non-Static Methods 956 (93.63%)
58+
Static Methods 65 (6.37%)
5959
Visibility
60-
Public Methods 803 (79.35%)
61-
Protected Methods 67 (6.62%)
62-
Private Methods 142 (14.03%)
60+
Public Methods 811 (79.43%)
61+
Protected Methods 67 (6.56%)
62+
Private Methods 143 (14.01%)
6363
Functions 37
6464
Named Functions 7 (18.92%)
6565
Anonymous Functions 30 (81.08%)

.tools/.report/.phploc/.test.phploc.report

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
phploc 7.0.2 by Sebastian Bergmann.
22

33
Directories 74
4-
Files 280
4+
Files 281
55

66
Size
7-
Lines of Code (LOC) 32668
8-
Comment Lines of Code (CLOC) 461 (1.41%)
9-
Non-Comment Lines of Code (NCLOC) 32207 (98.59%)
10-
Logical Lines of Code (LLOC) 7268 (22.25%)
11-
Classes 7260 (99.89%)
7+
Lines of Code (LOC) 32814
8+
Comment Lines of Code (CLOC) 462 (1.41%)
9+
Non-Comment Lines of Code (NCLOC) 32352 (98.59%)
10+
Logical Lines of Code (LLOC) 7297 (22.24%)
11+
Classes 7289 (99.89%)
1212
Average Class Length 26
1313
Minimum Class Length 0
1414
Maximum Class Length 871
@@ -18,9 +18,9 @@ Size
1818
Average Methods Per Class 6
1919
Minimum Methods Per Class 0
2020
Maximum Methods Per Class 21
21-
Functions 4 (0.06%)
21+
Functions 4 (0.05%)
2222
Average Function Length 0
23-
Not in classes or functions 4 (0.06%)
23+
Not in classes or functions 4 (0.05%)
2424

2525
Cyclomatic Complexity
2626
Average Complexity per LLOC 0.06
@@ -39,27 +39,27 @@ Dependencies
3939
Attribute Accesses 28
4040
Non-Static 23 (82.14%)
4141
Static 5 (17.86%)
42-
Method Calls 9998
43-
Non-Static 6679 (66.80%)
44-
Static 3319 (33.20%)
42+
Method Calls 10049
43+
Non-Static 6723 (66.90%)
44+
Static 3326 (33.10%)
4545

4646
Structure
4747
Namespaces 74
4848
Interfaces 1
4949
Traits 1
50-
Classes 277
50+
Classes 278
5151
Abstract Classes 4 (1.44%)
52-
Concrete Classes 273 (98.56%)
53-
Final Classes 255 (93.41%)
54-
Non-Final Classes 18 (6.59%)
55-
Methods 1839
52+
Concrete Classes 274 (98.56%)
53+
Final Classes 256 (93.43%)
54+
Non-Final Classes 18 (6.57%)
55+
Methods 1848
5656
Scope
57-
Non-Static Methods 1731 (94.13%)
58-
Static Methods 108 (5.87%)
57+
Non-Static Methods 1739 (94.10%)
58+
Static Methods 109 (5.90%)
5959
Visibility
60-
Public Methods 1114 (60.58%)
61-
Protected Methods 345 (18.76%)
62-
Private Methods 380 (20.66%)
60+
Public Methods 1120 (60.61%)
61+
Protected Methods 345 (18.67%)
62+
Private Methods 383 (20.73%)
6363
Functions 97
6464
Named Functions 2 (2.06%)
6565
Anonymous Functions 95 (97.94%)

src/Spinner/Container/Builder/ServiceBuilder.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
use AlecRabbit\Spinner\Container\Contract\IServiceBuilder;
99
use AlecRabbit\Spinner\Container\Service;
1010

11+
/**
12+
* @psalm-suppress PossiblyNullArgument
13+
*/
1114
final class ServiceBuilder implements IServiceBuilder
1215
{
1316
private mixed $value;
14-
private bool $isStorable;
15-
private string $id;
17+
private ?bool $isStorable = null;
18+
private ?string $id = null;
1619

1720
public function build(): IService
1821
{
@@ -29,8 +32,8 @@ private function validate(): void
2932
{
3033
match (true) {
3134
!isset($this->value) => throw new \InvalidArgumentException('Value is not set.'),
32-
!isset($this->id) || '' === $this->id => throw new \InvalidArgumentException('Id is not set.'),
33-
!isset($this->isStorable) => throw new \InvalidArgumentException('isStorable is not set.'),
35+
$this->id === null => throw new \InvalidArgumentException('Id is not set.'),
36+
$this->isStorable=== null => throw new \InvalidArgumentException('isStorable is not set.'),
3437
default => null,
3538
};
3639
}

src/Spinner/Container/Builder/ServiceSpawnerBuilder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use AlecRabbit\Spinner\Container\Contract\ICircularDependencyDetector;
88
use AlecRabbit\Spinner\Container\Contract\IContainer;
9-
use AlecRabbit\Spinner\Container\Contract\IServiceObjectFactory;
9+
use AlecRabbit\Spinner\Container\Contract\IServiceFactory;
1010
use AlecRabbit\Spinner\Container\Contract\IServiceSpawner;
1111
use AlecRabbit\Spinner\Container\Contract\IServiceSpawnerBuilder;
1212
use AlecRabbit\Spinner\Container\ServiceSpawner;
@@ -19,7 +19,7 @@ final class ServiceSpawnerBuilder implements IServiceSpawnerBuilder
1919
{
2020
private ?IContainer $container = null;
2121
private ?ICircularDependencyDetector $circularDependencyDetector = null;
22-
private ?IServiceObjectFactory $serviceObjectFactory = null;
22+
private ?IServiceFactory $serviceObjectFactory = null;
2323

2424
public function withContainer(IContainer $container): IServiceSpawnerBuilder
2525
{
@@ -58,7 +58,7 @@ public function withCircularDependencyDetector(ICircularDependencyDetector $dete
5858
return $clone;
5959
}
6060

61-
public function withServiceObjectFactory(IServiceObjectFactory $serviceObjectFactory): IServiceSpawnerBuilder
61+
public function withServiceObjectFactory(IServiceFactory $serviceObjectFactory): IServiceSpawnerBuilder
6262
{
6363
$clone = clone $this;
6464
$clone->serviceObjectFactory = $serviceObjectFactory;

src/Spinner/Container/Contract/IIsStorableSolver.php renamed to src/Spinner/Container/Contract/IIsStorableResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace AlecRabbit\Spinner\Container\Contract;
66

7-
interface IIsStorableSolver
7+
interface IIsStorableResolver
88
{
99
public function isStorable(IServiceDefinition $definition): bool;
1010
}

src/Spinner/Container/Contract/IServiceObjectFactory.php renamed to src/Spinner/Container/Contract/IServiceFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace AlecRabbit\Spinner\Container\Contract;
66

7-
interface IServiceObjectFactory
7+
interface IServiceFactory
88
{
99
public function create(mixed $value, IServiceDefinition $serviceDefinition): IService;
1010
}

src/Spinner/Container/Contract/IServiceSpawnerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ public function withCircularDependencyDetector(ICircularDependencyDetector $dete
1212

1313
public function build(): IServiceSpawner;
1414

15-
public function withServiceObjectFactory(IServiceObjectFactory $serviceObjectFactory): IServiceSpawnerBuilder;
15+
public function withServiceObjectFactory(IServiceFactory $serviceObjectFactory): IServiceSpawnerBuilder;
1616
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AlecRabbit\Spinner\Container\Factory;
6+
7+
use AlecRabbit\Spinner\Container\Builder\ServiceBuilder;
8+
use AlecRabbit\Spinner\Container\Contract\IIsStorableResolver;
9+
use AlecRabbit\Spinner\Container\Contract\IService;
10+
use AlecRabbit\Spinner\Container\Contract\IServiceBuilder;
11+
use AlecRabbit\Spinner\Container\Contract\IServiceDefinition;
12+
use AlecRabbit\Spinner\Container\Contract\IServiceFactory;
13+
use AlecRabbit\Spinner\Container\ServiceIsStorableResolver;
14+
15+
final readonly class ServiceFactory implements IServiceFactory
16+
{
17+
public function __construct(
18+
private IIsStorableResolver $isStorableResolver = new ServiceIsStorableResolver(),
19+
private IServiceBuilder $serviceBuilder = new ServiceBuilder(),
20+
) {
21+
}
22+
23+
public function create(mixed $value, IServiceDefinition $serviceDefinition): IService
24+
{
25+
$id = $serviceDefinition->getId();
26+
$isStorable = $this->isStorableResolver->isStorable($serviceDefinition);
27+
28+
return $this->serviceBuilder
29+
->withValue($value)
30+
->withId($id)
31+
->withIsStorable($isStorable)
32+
->build()
33+
;
34+
}
35+
}

src/Spinner/Container/Factory/ServiceObjectFactory.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)