Skip to content

Commit

Permalink
fix theme overridden
Browse files Browse the repository at this point in the history
Apply theme immediately so it can be overridden later by setter
  • Loading branch information
uyab committed Dec 4, 2019
1 parent cc7f1e7 commit a3e94f7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Avatar.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public function applyTheme(array $config)

$this->setForeground($this->getRandomForeground());
$this->setBackground($this->getRandomBackground());
$this->setFont($this->getRandomFont());
}

public function addTheme(string $name, array $config)
Expand All @@ -148,6 +149,8 @@ public function setTheme($theme)
$this->theme = $theme;
}

$this->setRandomTheme();

return $this;
}

Expand Down Expand Up @@ -366,11 +369,9 @@ protected function getRandomForeground()
return $this->getRandomElement($this->availableForegrounds, $this->foreground);
}

protected function setRandomFont()
protected function getRandomFont()
{
$randomFont = $this->getRandomElement($this->fonts, $this->defaultFont);

$this->setFont($randomFont);
return $this->getRandomElement($this->fonts, $this->defaultFont);
}

protected function getBorderColor()
Expand All @@ -388,8 +389,6 @@ protected function getBorderColor()
public function buildAvatar()
{
$this->buildInitial();
$this->setRandomTheme();
$this->setRandomFont();

$x = $this->width / 2;
$y = $this->height / 2;
Expand Down

0 comments on commit a3e94f7

Please sign in to comment.