-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de6706f
commit 62fcb8a
Showing
25 changed files
with
944 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/PROCERGS/LoginCidadao/CpfVerificationBundle/DependencyInjection/Configuration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace PROCERGS\LoginCidadao\CpfVerificationBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
/** | ||
* This is the class that validates and merges configuration from your app/config files | ||
* | ||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} | ||
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfigTreeBuilder() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
$rootNode = $treeBuilder->root('procergs_login_cidadao_cpf_verification'); | ||
|
||
// Here you should define the parameters that are allowed to | ||
// configure your bundle. See the documentation linked above for | ||
// more information on that topic. | ||
|
||
return $treeBuilder; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...pfVerificationBundle/DependencyInjection/PROCERGSLoginCidadaoCpfVerificationExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace PROCERGS\LoginCidadao\CpfVerificationBundle\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
|
||
/** | ||
* This is the class that loads and manages your bundle configuration | ||
* | ||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} | ||
*/ | ||
class PROCERGSLoginCidadaoCpfVerificationExtension extends Extension | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$configuration = new Configuration(); | ||
$config = $this->processConfiguration($configuration, $configs); | ||
|
||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | ||
$loader->load('services.yml'); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/PROCERGS/LoginCidadao/CpfVerificationBundle/Exception/CpfNotSubscribedToNfgException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* This file is part of the login-cidadao project or it's bundles. | ||
* | ||
* (c) Guilherme Donato <guilhermednt on github> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PROCERGS\LoginCidadao\CpfVerificationBundle\Exception; | ||
|
||
use Throwable; | ||
|
||
class CpfNotSubscribedToNfgException extends \RuntimeException | ||
{ | ||
public const ERROR_CODE = 'cpf_not_subscribed_to_nfg'; | ||
|
||
/** @var string */ | ||
private $cpf; | ||
|
||
public function __construct(string $cpf, string $message = "", int $code = 0, Throwable $previous = null) | ||
{ | ||
$this->cpf = $cpf; | ||
parent::__construct($message, $code, $previous); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCpf(): string | ||
{ | ||
return $this->cpf; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/PROCERGS/LoginCidadao/CpfVerificationBundle/Exception/WrongAnswerException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* This file is part of the login-cidadao project or it's bundles. | ||
* | ||
* (c) Guilherme Donato <guilhermednt on github> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PROCERGS\LoginCidadao\CpfVerificationBundle\Exception; | ||
|
||
use PROCERGS\LoginCidadao\CpfVerificationBundle\Model\ChallengeInterface; | ||
use Throwable; | ||
|
||
class WrongAnswerException extends \RuntimeException | ||
{ | ||
/** @var ChallengeInterface */ | ||
private $challenge; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function __construct( | ||
ChallengeInterface $challenge, | ||
string $message = "", | ||
int $code = 0, | ||
Throwable $previous = null | ||
) { | ||
$this->challenge = $challenge; | ||
parent::__construct($message, $code, $previous); | ||
} | ||
|
||
/** | ||
* @return ChallengeInterface | ||
*/ | ||
public function getChallenge(): ChallengeInterface | ||
{ | ||
return $this->challenge; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/PROCERGS/LoginCidadao/CpfVerificationBundle/Model/AbstractChallenge.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/** | ||
* This file is part of the login-cidadao project or it's bundles. | ||
* | ||
* (c) Guilherme Donato <guilhermednt on github> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PROCERGS\LoginCidadao\CpfVerificationBundle\Model; | ||
|
||
abstract class AbstractChallenge implements ChallengeInterface | ||
{ | ||
/** @var string */ | ||
private $cpf; | ||
|
||
/** @var int */ | ||
private $attemptsLeft; | ||
|
||
/** | ||
* Challenge constructor. | ||
* @param string $cpf | ||
* @param int $attemptsLeft | ||
*/ | ||
public function __construct(int $attemptsLeft, string $cpf) | ||
{ | ||
$this->cpf = $cpf; | ||
$this->attemptsLeft = $attemptsLeft; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCpf(): string | ||
{ | ||
return $this->cpf; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getAttemptsLeft(): int | ||
{ | ||
return $this->attemptsLeft; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/PROCERGS/LoginCidadao/CpfVerificationBundle/Model/ChallengeFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/** | ||
* This file is part of the login-cidadao project or it's bundles. | ||
* | ||
* (c) Guilherme Donato <guilhermednt on github> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PROCERGS\LoginCidadao\CpfVerificationBundle\Model; | ||
|
||
class ChallengeFactory | ||
{ | ||
public static function create( | ||
string $challengeName, | ||
int $attemptsLeft, | ||
string $cpf, | ||
array $choices = null | ||
): ChallengeInterface { | ||
switch ($challengeName) { | ||
case SelectMotherInitialsChallenge::CHALLENGE_NAME: | ||
return new SelectMotherInitialsChallenge($attemptsLeft, $cpf, $choices ?? []); | ||
case TypeBirthdayChallenge::CHALLENGE_NAME: | ||
return new TypeBirthdayChallenge($attemptsLeft, $cpf); | ||
case TypeMotherInitialsChallenge::CHALLENGE_NAME: | ||
return new TypeMotherInitialsChallenge($attemptsLeft, $cpf); | ||
case TypePostalCodeChallenge::CHALLENGE_NAME: | ||
return new TypePostalCodeChallenge($attemptsLeft, $cpf); | ||
case TypeVoterRegistrationChallenge::CHALLENGE_NAME: | ||
return new TypeVoterRegistrationChallenge($attemptsLeft, $cpf); | ||
default: | ||
throw new \InvalidArgumentException("Unsupported challenge '{$challengeName}'"); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/PROCERGS/LoginCidadao/CpfVerificationBundle/Model/ChallengeInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* This file is part of the login-cidadao project or it's bundles. | ||
* | ||
* (c) Guilherme Donato <guilhermednt on github> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PROCERGS\LoginCidadao\CpfVerificationBundle\Model; | ||
|
||
interface ChallengeInterface | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getName(): string; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCpf(): string; | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getAttemptsLeft(): int; | ||
} |
47 changes: 47 additions & 0 deletions
47
src/PROCERGS/LoginCidadao/CpfVerificationBundle/Model/SelectMotherInitialsChallenge.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/** | ||
* This file is part of the login-cidadao project or it's bundles. | ||
* | ||
* (c) Guilherme Donato <guilhermednt on github> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PROCERGS\LoginCidadao\CpfVerificationBundle\Model; | ||
|
||
class SelectMotherInitialsChallenge extends AbstractChallenge | ||
{ | ||
public const CHALLENGE_NAME = 'select_mother_initials'; | ||
|
||
/** @var string[] */ | ||
private $choices; | ||
|
||
/** | ||
* SelectMotherInitialsChallenge constructor. | ||
* @param int $attemptsLeft | ||
* @param string $cpf | ||
* @param string[] $choices | ||
*/ | ||
public function __construct(int $attemptsLeft, string $cpf, array $choices) | ||
{ | ||
$this->choices = $choices; | ||
parent::__construct($attemptsLeft, $cpf); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getName(): string | ||
{ | ||
return self::CHALLENGE_NAME; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getChoices(): array | ||
{ | ||
return $this->choices; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/PROCERGS/LoginCidadao/CpfVerificationBundle/Model/TypeBirthdayChallenge.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* This file is part of the login-cidadao project or it's bundles. | ||
* | ||
* (c) Guilherme Donato <guilhermednt on github> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PROCERGS\LoginCidadao\CpfVerificationBundle\Model; | ||
|
||
class TypeBirthdayChallenge extends AbstractChallenge | ||
{ | ||
public const CHALLENGE_NAME = 'type_birthday'; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getName(): string | ||
{ | ||
return self::CHALLENGE_NAME; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/PROCERGS/LoginCidadao/CpfVerificationBundle/Model/TypeMotherInitialsChallenge.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* This file is part of the login-cidadao project or it's bundles. | ||
* | ||
* (c) Guilherme Donato <guilhermednt on github> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PROCERGS\LoginCidadao\CpfVerificationBundle\Model; | ||
|
||
class TypeMotherInitialsChallenge extends AbstractChallenge | ||
{ | ||
public const CHALLENGE_NAME = 'type_mother_initials'; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getName(): string | ||
{ | ||
return self::CHALLENGE_NAME; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/PROCERGS/LoginCidadao/CpfVerificationBundle/Model/TypePostalCodeChallenge.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* This file is part of the login-cidadao project or it's bundles. | ||
* | ||
* (c) Guilherme Donato <guilhermednt on github> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PROCERGS\LoginCidadao\CpfVerificationBundle\Model; | ||
|
||
class TypePostalCodeChallenge extends AbstractChallenge | ||
{ | ||
public const CHALLENGE_NAME = 'type_postal_code'; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getName(): string | ||
{ | ||
return self::CHALLENGE_NAME; | ||
} | ||
} |
Oops, something went wrong.