Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
11 / 11
CRAP
100.00% covered (success)
100.00%
28 / 28
Factory
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
11 / 11
11
100.00% covered (success)
100.00%
28 / 28
 __construct(Configuration $configuration)
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getConfiguration()
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getEmailValidator()
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getPasswordValidator()
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
4 / 4
 getUserTypeValidator()
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getUserValidator()
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
 getPasswordGenerator()
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
 getPasswordHasher()
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getUserPersistentStorage()
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getUserRepository()
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getRegistrationModule()
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
6 / 6
<?php
namespace Tdd;
class Factory
{
    /** @var Configuration */
    private $configuration;
    public function __construct(Configuration $configuration)
    {
        $this->configuration = $configuration;
    }
    /**
     * @return Configuration
     */
    public function getConfiguration()
    {
        return $this->configuration;
    }
    public function getEmailValidator()
    {
        return new EmailValidator;
    }
    public function getPasswordValidator()
    {
        return new PasswordValidator(
            $this->configuration->get(Key::CONFIGURATION_VALIDATOR_USER_PASSWORD_MINIMUM_LENGTH),
            $this->configuration->get(Key::CONFIGURATION_VALIDATOR_USER_PASSWORD_MAXIMUM_LENGTH)
        );
    }
    public function getUserTypeValidator()
    {
        return new UserTypeValidator();
    }
    public function getUserValidator()
    {
        return new UserValidator(
            $this->getEmailValidator(),
            $this->getPasswordValidator(),
            $this->getUserTypeValidator()
        );
    }
    public function getPasswordGenerator()
    {
        return new PasswordGenerator(
            $this->configuration->get(Key::CONFIGURATION_VALIDATOR_USER_PASSWORD_MINIMUM_LENGTH),
            $this->configuration->get(Key::CONFIGURATION_VALIDATOR_USER_PASSWORD_MAXIMUM_LENGTH),
            $this->configuration->get(Key::CONFIGURATION_VALIDATOR_USER_PASSWORD_CHARACTER_SET)
        );
    }
    public function getPasswordHasher()
    {
        return new PasswordHasher();
    }
    public function getUserPersistentStorage()
    {
        return new SqliteStorage($this->configuration->get(Key::CONFIGURATION_STORAGE_USER_DATABASE_CONFIGURATION));
    }
    public function getUserRepository()
    {
        return new UserRepository($this->getUserPersistentStorage());
    }
    public function getRegistrationModule()
    {
        return new RegistrationModule(
            $this->getUserRepository(),
            $this->getUserValidator(),
            $this->getPasswordHasher(),
            $this->getPasswordGenerator()
        );
    }
}