public function testToFromArray() { $key = 'key'; $secret = 'secret'; $keySecret = new KeySecret($key, $secret); $keySecretArr = $keySecret->toArray(); $this->assertEquals($key, $keySecretArr[$key]); $this->assertEquals($secret, $keySecretArr[$secret]); $this->assertEquals($keySecret, KeySecret::fromArray($keySecretArr)); }
/** * @param array $data * * @return KeySecretConfig * * @throws InvalidArgumentException */ public static function fromArray(array $data) { if (!isset($data[static::CREDENTIAL_KEY])) { throw new InvalidArgumentException('At key secret config from array missing the credential'); } return new static(KeySecret::fromArray($data[static::CREDENTIAL_KEY]), static::getFromArrayActive($data), static::getFromArrayExpired($data), static::getFromArrayLocked($data)); }