ChocolateChip.php in Bakery Single Sign-On System 8.2
File
src/Cookies/ChocolateChip.php
View source
<?php
namespace Drupal\bakery\Cookies;
class ChocolateChip implements CookieInterface {
use BrowserCookieTrait;
protected $name;
protected $mail;
protected $init;
protected $isMain;
private $calories = 480;
public final function __construct($name, $mail, $init, $is_main = NULL) {
$this->name = $name;
$this->mail = $mail;
$this->init = $init;
$this->isMain = $is_main;
}
public static function fromData(array $data) {
return new static($data['name'] ?? '', $data['mail'] ?? '', $data['init'] ?? '');
}
public function toData() : array {
return [
'name' => $this->name,
'mail' => $this->mail,
'init' => $this->init,
'master' => $this->isMain ?? $this
->getIsMain(),
'calories' => $this->calories,
];
}
public static function getName() : string {
return static::cookieName('CHOCOLATECHIP');
}
public function getAccountName() : string {
return $this->name;
}
public function getEmail() : string {
return $this->mail;
}
public function getInit() : string {
return $this->init;
}
}