Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgmyr committed Jan 25, 2019
1 parent 64efe41 commit eab5217
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/TitleFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TitleFormatter
*
* @var string|null
*/
protected $title = null;
protected $title;

/**
* The separator character for in between words.
Expand Down Expand Up @@ -60,12 +60,10 @@ class TitleFormatter
];

/**
* Construct, just needs the title to get going.
*
* @param string $title
* @param string $separator
*/
public function __construct($title, $separator = ' ')
private function __construct($title, $separator = ' ')
{
$this->setTitle($title);
$this->separator = $separator;
Expand Down Expand Up @@ -100,10 +98,7 @@ public function convertTitle()
*/
public static function titleCase($title, $separator = ' ')
{
// hack in order to keep static method call
$obj = new TitleFormatter($title, $separator);

return $obj->convertTitle();
return (new self($title, $separator))->convertTitle();
}

/**
Expand Down Expand Up @@ -137,7 +132,7 @@ protected function splitWords()
$wordIndex = $this->getWordIndex($word, $offset);

if ($this->hasDash($word)) {
$word = TitleFormatter::titleCase($word, '-');
$word = self::titleCase($word, '-');
$this->rebuildTitle($wordIndex, $word);
}

Expand Down

0 comments on commit eab5217

Please sign in to comment.