File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed
Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -19,39 +19,43 @@ class Pluralizer
1919
2020 private $ word ;
2121
22- public function __construct (string $ word )
22+ public function __construct (Word $ word )
2323 {
2424 $ this ->word = $ word ;
2525 }
2626
2727 public function pluralize ()
2828 {
2929 if ($ this ->isUncountable ()) {
30- return $ this ->word ;
30+ return new Word ( $ this ->word ) ;
3131 }
3232
3333 foreach ($ this ->irregular as $ singular => $ plural ) {
3434 if ($ singular ==$ this ->word ) {
35- return $ plural ;
35+ return new Word ( $ plural) ;
3636 }
3737 }
3838
39- return Inflector::pluralize ($ this ->word );
39+ $ plural = Inflector::pluralize ((string ) $ this ->word );
40+
41+ return new Word ($ plural );
4042 }
4143
4244 public function singularize ()
4345 {
4446 if ($ this ->isUncountable ()) {
45- return $ this ->word ;
47+ return new Word ( $ this ->word ) ;
4648 }
4749
4850 foreach ($ this ->irregular as $ singular => $ plural ) {
4951 if ($ plural ==$ this ->word ) {
50- return $ singular ;
52+ return new Word ( $ singular) ;
5153 }
5254 }
5355
54- return Inflector::singularize ($ this ->word );
56+ $ singular = Inflector::singularize ((string ) $ this ->word );
57+
58+ return new Word ($ singular );
5559 }
5660
5761 private function isUncountable ()
Original file line number Diff line number Diff line change @@ -77,12 +77,12 @@ public function syllables()
7777
7878 public function plural ()
7979 {
80- return (new Pluralizer ($ this -> word ))->pluralize ();
80+ return (new Pluralizer ($ this ))->pluralize ();
8181 }
8282
8383 public function singular ()
8484 {
85- return (new Pluralizer ($ this -> word ))->singularize ();
85+ return (new Pluralizer ($ this ))->singularize ();
8686 }
8787
8888 public function offensive ()
You can’t perform that action at this time.
0 commit comments