PHP code example of creonit / verification-code-bundle
1. Go to this page and download the library: Download creonit/verification-code-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
creonit / verification-code-bundle example snippets
use Creonit\VerificationCodeBundle\Generator\AbstractCodeGenerator;
use Creonit\VerificationCodeBundle\Generator\Exception\InvalidConfigurationException;
class MyCodeGenerator extends AbstractCodeGenerator
{
public function generate(string $key)
{
return 'code';
}
protected function validateConfig(array $config)
{
$
use Creonit\VerificationCodeBundle\CodeManager;
use Creonit\VerificationCodeBundle\Context\CodeContext;
class PhoneVerificationService
{
/**
* @var CodeManager
*/
protected $codeManager;
public function __construct(CodeManager $codeManager)
{
$this->codeManager = $codeManager;
}
/**
* @param string $key
*
* @return \Creonit\VerificationCodeBundle\Model\VerificationCodeInterface
*/
public function generateCode(string $key)
{
$context = new CodeContext($key, 'scope_name');
return $this->codeManager->createCode($context);
}
}
use Creonit\VerificationCodeBundle\CodeManager;
use Creonit\VerificationCodeBundle\Context\CodeContext;
class PhoneVerificationService
{
/**
* @var CodeManager
*/
protected $codeManager;
public function __construct(CodeManager $codeManager)
{
$this->codeManager = $codeManager;
}
/**
* @param string $key
* @param string $code
*
* @return bool
*/
public function verificationCode(string $key, string $code)
{
$context = new CodeContext($key, 'scope_name');
$context->setCode($code);
return $this->codeManager->verificationCode($context);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.