@@ -9,7 +9,7 @@ class TitleFormatter
9
9
*
10
10
* @var string|null
11
11
*/
12
- protected $ title = null ;
12
+ protected $ title ;
13
13
14
14
/**
15
15
* The separator character for in between words.
@@ -60,12 +60,10 @@ class TitleFormatter
60
60
];
61
61
62
62
/**
63
- * Construct, just needs the title to get going.
64
- *
65
63
* @param string $title
66
64
* @param string $separator
67
65
*/
68
- public function __construct ($ title , $ separator = ' ' )
66
+ private function __construct ($ title , $ separator = ' ' )
69
67
{
70
68
$ this ->setTitle ($ title );
71
69
$ this ->separator = $ separator ;
@@ -100,10 +98,7 @@ public function convertTitle()
100
98
*/
101
99
public static function titleCase ($ title , $ separator = ' ' )
102
100
{
103
- // hack in order to keep static method call
104
- $ obj = new TitleFormatter ($ title , $ separator );
105
-
106
- return $ obj ->convertTitle ();
101
+ return (new self ($ title , $ separator ))->convertTitle ();
107
102
}
108
103
109
104
/**
@@ -137,7 +132,7 @@ protected function splitWords()
137
132
$ wordIndex = $ this ->getWordIndex ($ word , $ offset );
138
133
139
134
if ($ this ->hasDash ($ word )) {
140
- $ word = TitleFormatter ::titleCase ($ word , '- ' );
135
+ $ word = self ::titleCase ($ word , '- ' );
141
136
$ this ->rebuildTitle ($ wordIndex , $ word );
142
137
}
143
138
0 commit comments