for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sinergi\Users\User;
use Interop\Container\ContainerInterface;
use Sinergi\Users\Container;
class UserValidator
{
public function __construct(ContainerInterface $container)
if ($container instanceof Container) {
$this->container = $container;
container
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
} else {
$this->container = new Container($container);
}
public function __invoke(UserEntityInterface $user): array
$errors = [];
/** @var UserRepositoryInterface $userRepository */
$userRepository = $this->container->get(UserRepositoryInterface::class);
$userExists = $userRepository->findByEmail($user->getEmail());
if ($userExists && (!$user->getId() || ($user->getId() !== $userExists->getId()))) {
$errors[1300] = 'Email is already in user';
if (empty($user->getPassword())) {
$errors[1301] = 'Password is empty';
return $errors;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: