Skip to content

Commit 25698f8

Browse files
committed
make Edge\Shape an enum
1 parent b344e0c commit 25698f8

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

src/Edge/Shape.php

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,112 +6,110 @@
66
/**
77
* @psalm-immutable
88
*/
9-
final class Shape
9+
enum Shape
1010
{
11-
private string $value;
12-
private string $modifier;
13-
private string $side;
14-
15-
private function __construct(
16-
string $value,
17-
string $modifier = '',
18-
string $side = '',
19-
) {
20-
$this->value = $value;
21-
$this->modifier = $modifier;
22-
$this->side = $side;
23-
}
11+
case box;
12+
case crow;
13+
case curve;
14+
case icurve;
15+
case diamond;
16+
case dot;
17+
case inv;
18+
case none;
19+
case normal;
20+
case tee;
21+
case vee;
2422

2523
/**
2624
* @psalm-pure
2725
*/
2826
public static function box(): self
2927
{
30-
return new self('box');
28+
return self::box;
3129
}
3230

3331
/**
3432
* @psalm-pure
3533
*/
3634
public static function crow(): self
3735
{
38-
return new self('crow');
36+
return self::crow;
3937
}
4038

4139
/**
4240
* @psalm-pure
4341
*/
4442
public static function curve(): self
4543
{
46-
return new self('curve');
44+
return self::curve;
4745
}
4846

4947
/**
5048
* @psalm-pure
5149
*/
5250
public static function icurve(): self
5351
{
54-
return new self('icurve');
52+
return self::icurve;
5553
}
5654

5755
/**
5856
* @psalm-pure
5957
*/
6058
public static function diamond(): self
6159
{
62-
return new self('diamond');
60+
return self::diamond;
6361
}
6462

6563
/**
6664
* @psalm-pure
6765
*/
6866
public static function dot(): self
6967
{
70-
return new self('dot');
68+
return self::dot;
7169
}
7270

7371
/**
7472
* @psalm-pure
7573
*/
7674
public static function inv(): self
7775
{
78-
return new self('inv');
76+
return self::inv;
7977
}
8078

8179
/**
8280
* @psalm-pure
8381
*/
8482
public static function none(): self
8583
{
86-
return new self('none');
84+
return self::none;
8785
}
8886

8987
/**
9088
* @psalm-pure
9189
*/
9290
public static function normal(): self
9391
{
94-
return new self('normal');
92+
return self::normal;
9593
}
9694

9795
/**
9896
* @psalm-pure
9997
*/
10098
public static function tee(): self
10199
{
102-
return new self('tee');
100+
return self::tee;
103101
}
104102

105103
/**
106104
* @psalm-pure
107105
*/
108106
public static function vee(): self
109107
{
110-
return new self('vee');
108+
return self::vee;
111109
}
112110

113111
public function toString(): string
114112
{
115-
return $this->value;
113+
return $this->name;
116114
}
117115
}

0 commit comments

Comments
 (0)