Skip to content

Commit

Permalink
RedundantPropertyInitializationCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-42 committed Dec 19, 2020
1 parent f96808d commit 5004b94
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Icon.php
Expand Up @@ -35,8 +35,8 @@ class Icon implements IconInterface
*/
private string $name;

/** @var string Sets a title to the SVG output */
private string $title;
/** @var null|string Sets a title to the SVG output */
private ?string $title;

/**
* @var int The width of the icon. This will dismiss the automatic height
Expand All @@ -45,6 +45,11 @@ class Icon implements IconInterface
*/
private int $width;

public function __construct()
{
$this->title = null;
}

/**
* @see $icon
* @param string $key
Expand All @@ -61,12 +66,7 @@ public function get(string $key)
*/
public function getTitle(): string
{
if (isset($this->title)) {
return $this->title;
}

$name = basename($this->name ?? '', '.svg');
return $name;
return $this->title ?? basename($this->name, '.svg');
}

public function setClass(string $value): void
Expand Down

0 comments on commit 5004b94

Please sign in to comment.