Skip to content

Commit

Permalink
allowSpecialCharacters
Browse files Browse the repository at this point in the history
  • Loading branch information
LasseRafn committed Feb 17, 2020
1 parent 3f57081 commit 817823d
Showing 1 changed file with 41 additions and 16 deletions.
57 changes: 41 additions & 16 deletions src/InitialAvatar.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,22 @@ class InitialAvatar
/** @var Initials */
protected $initials_generator;

protected $driver = 'gd'; // imagick or gd
protected $fontSize = 0.5;
protected $name = 'John Doe';
protected $width = 48;
protected $height = 48;
protected $bgColor = '#f0e9e9';
protected $fontColor = '#8b5d5d';
protected $rounded = false;
protected $smooth = false;
protected $autofont = false;
protected $keepCase = false;
protected $fontFile = '/fonts/OpenSans-Regular.ttf';
protected $fontName = 'OpenSans, sans-serif';
protected $generated_initials = 'JD';
protected $preferBold = false;
protected $driver = 'gd'; // imagick or gd
protected $fontSize = 0.5;
protected $name = 'John Doe';
protected $width = 48;
protected $height = 48;
protected $bgColor = '#f0e9e9';
protected $fontColor = '#8b5d5d';
protected $rounded = false;
protected $smooth = false;
protected $autofont = false;
protected $keepCase = false;
protected $allowSpecialCharacters = true;
protected $fontFile = '/fonts/OpenSans-Regular.ttf';
protected $fontName = 'OpenSans, sans-serif';
protected $generated_initials = 'JD';
protected $preferBold = false;

/**
* Language eg.en zh-CN
Expand Down Expand Up @@ -313,6 +314,19 @@ public function keepCase( $keepCase = true ) {
return $this;
}

/**
* Set if should allow (or remove) special characters
*
* @param bool $allowSpecialCharacters
*
* @return $this
*/
public function allowSpecialCharacters( $allowSpecialCharacters = true ) {
$this->allowSpecialCharacters = (bool) $allowSpecialCharacters;

return $this;
}

/**
* Set the font size in percentage
* (0.1 = 10%).
Expand All @@ -337,7 +351,9 @@ public function fontSize( $size = 0.5 ) {
public function generate( $name = null ) {
if ( $name !== null ) {
$this->name = $name;
$this->generated_initials = $this->initials_generator->keepCase( $this->getKeepCase() )->generate( $name );
$this->generated_initials = $this->initials_generator->keepCase( $this->getKeepCase() )
->allowSpecialCharacters( $this->getAllowSpecialCharacters() )
->generate( $name );
}

return $this->makeAvatar( $this->image );
Expand Down Expand Up @@ -474,6 +490,15 @@ public function getKeepCase() {
return $this->keepCase;
}

/**
* Will return the allowSpecialCharacters parameter.
*
* @return boolean
*/
public function getAllowSpecialCharacters() {
return $this->allowSpecialCharacters;
}

/**
* Will return the autofont parameter.
*
Expand Down

0 comments on commit 817823d

Please sign in to comment.