Bacon/BaconUser — pull request #27 by bakura10 (2013-08-29 16:44:57+00:00)
Title: Various cleanup

There are a various other things I've seen but I'd like to discuss with @Ocramius and @DASPRID before changing it:

1) There are a lot of factories scattered at different places in the code. For instance, "Password" have a subfolder "Factory", while Repositories factories are in the top-root "Factory" folder. I'd like if we had somehting cohernet on that. As the module is pretty specific and should not end with a lot of new features everyday, I'd be in favor of moving all the factories to the top Factory folder. What do you think?

2) There is a "allowed_login_states" option, but I can't understand it. It's not used across the code base, adn the name is a bit misleading. I think it should be called "allowed_user_states" and be used either in the User entity before setting the user state, or somewhere in a service, throwing some kind of "InvalidUserStateException". But even, I don't really like this method. I think the user state should belong to the entity class and be defined there. There are not really "options", they are part of the entity's logic. So maybe we could remove it and doing something like that in the User entity:

```php
protected $allowedStates = null;

public function setState($state)
{
if (!is_array($this->allowedStates) || !in_array($state, $this->allowedStates) {
throw Exception;
}

$this->state = $state;
}
```

And people shoudl just extend the User class, and setting the allowedStates property.

3) For all the Options classes, it makes no sense to have fluent interfaces, as they are created and used by factories. I'd be in favour of removing all the return $this for all options classes.