Codor
Codor copied to clipboard
Sniff to prevent conditionals in constructors
Extracted from #71
With the exception for Immutable Values Objects constructors should only accept objects and their body we should only see them assigned to private properties.
So calls to collaborators methods, self methods or any other kind of logic MUST NOT be presented in the body of a constructor.
<?php
class UserHandler
{
private $userRepo;
public function __construct(UserRepositoryContract $userRepo)
{
$this->userRepo = $userRepo;
}
}