I am currently refactoring bits of a medium sized project and encountered the following. (Bit of pseudo code to simplify the example)
class PostRepository {
}
class PostManager {
/**
* @var PostRepository
*/
private $repository;
public function __construct(PostRepository $repository)
{
$this->repository = $repository;
}
}
class DeletePostCommand {
/**
* @var PostManager
*/
private $postManager;
/**
* @var PostRepository
*/
private $postRepository;
public function __construct(PostManager $postManager, PostRepository $postRepository)
{
$this->postManager = $postManager;
$this->postRepository = $postRepository;
}
}
Should this be refactored? Or is it fine as it is?
Or should I create a getPostRepository
function in my PostManager
class? Wouldn't that go against the idea of the Single Responsibility Principle?