@@ -41,8 +41,8 @@ enum Facing{
4141 /**
4242 * Returns the axis of the given direction.
4343 */
44- public static function axis (Facing $ direction ) : Axis {
45- return match ($ direction ) {
44+ public function axis () : Axis {
45+ return match ($ this ) {
4646 self ::DOWN , self ::UP => Axis::Y,
4747 self ::NORTH , self ::SOUTH => Axis::Z,
4848 self ::WEST , self ::EAST => Axis::X,
@@ -66,15 +66,15 @@ public function offset() : array{
6666 /**
6767 * Returns whether the direction is facing the positive of its axis.
6868 */
69- public static function isPositive (Facing $ direction ) : bool {
70- return $ direction === self ::UP || $ direction === self ::SOUTH || $ direction === self ::EAST ;
69+ public function isPositive () : bool {
70+ return $ this === self ::UP || $ this === self ::SOUTH || $ this === self ::EAST ;
7171 }
7272
7373 /**
7474 * Returns the opposite Facing of the specified one.
7575 */
76- public static function opposite (Facing $ direction ) : Facing {
77- return match ($ direction ) {
76+ public function opposite () : Facing {
77+ return match ($ this ) {
7878 self ::DOWN => self ::UP ,
7979 self ::UP => self ::DOWN ,
8080 self ::NORTH => self ::SOUTH ,
@@ -87,43 +87,43 @@ public static function opposite(Facing $direction) : Facing{
8787 /**
8888 * Rotates the given direction around the axis.
8989 */
90- public static function rotate (Facing $ direction , Axis $ axis , bool $ clockwise ) : Facing {
90+ public function rotate (Axis $ axis , bool $ clockwise ) : Facing {
9191 $ rotated = match ($ axis ) {
92- Axis::Y => match ($ direction ) {
92+ Axis::Y => match ($ this ) {
9393 self ::NORTH => self ::EAST ,
9494 self ::EAST => self ::SOUTH ,
9595 self ::SOUTH => self ::WEST ,
9696 self ::WEST => self ::NORTH ,
97- default => throw new \InvalidArgumentException ("Face " . strtolower ($ direction ->name ) . " not match with Axis " . strtolower ($ axis ->name ))
97+ default => throw new \InvalidArgumentException ("Face " . strtolower ($ this ->name ) . " not match with Axis " . strtolower ($ axis ->name ))
9898 },
99- Axis::Z => match ($ direction ) {
99+ Axis::Z => match ($ this ) {
100100 self ::UP => self ::EAST ,
101101 self ::EAST => self ::DOWN ,
102102 self ::DOWN => self ::WEST ,
103103 self ::WEST => self ::UP ,
104- default => throw new \InvalidArgumentException ("Face " . strtolower ($ direction ->name ) . " not match with Axis " . strtolower ($ axis ->name ))
104+ default => throw new \InvalidArgumentException ("Face " . strtolower ($ this ->name ) . " not match with Axis " . strtolower ($ axis ->name ))
105105 },
106- Axis::X => match ($ direction ) {
106+ Axis::X => match ($ this ) {
107107 self ::UP => self ::NORTH ,
108108 self ::NORTH => self ::DOWN ,
109109 self ::DOWN => self ::SOUTH ,
110110 self ::SOUTH => self ::UP ,
111- default => throw new \InvalidArgumentException ("Face " . strtolower ($ direction ->name ) . " not match with Axis " . strtolower ($ axis ->name ))
111+ default => throw new \InvalidArgumentException ("Face " . strtolower ($ this ->name ) . " not match with Axis " . strtolower ($ axis ->name ))
112112 }
113113 };
114114
115- return $ clockwise ? $ rotated : self :: opposite ( $ rotated );
115+ return $ clockwise ? $ rotated : $ rotated-> opposite ( );
116116 }
117117
118- public static function rotateY (Facing $ direction , bool $ clockwise ) : Facing {
119- return self :: rotate ($ direction , Axis::Y, $ clockwise );
118+ public function rotateY (bool $ clockwise ) : Facing {
119+ return $ this -> rotate (Axis::Y, $ clockwise );
120120 }
121121
122- public static function rotateZ (Facing $ direction , bool $ clockwise ) : Facing {
123- return self :: rotate ($ direction , Axis::Z, $ clockwise );
122+ public function rotateZ (bool $ clockwise ) : Facing {
123+ return $ this -> rotate (Axis::Z, $ clockwise );
124124 }
125125
126- public static function rotateX (Facing $ direction , bool $ clockwise ) : Facing {
127- return self :: rotate ($ direction , Axis::X, $ clockwise );
126+ public function rotateX (bool $ clockwise ) : Facing {
127+ return $ this -> rotate (Axis::X, $ clockwise );
128128 }
129129}
0 commit comments