Asking a question should not change the answer
class ProductService
{
public function getProduct($id)
{
if (!$this->_productRepository->has($id)) {
$this->_productRepository->create($id);
}
return $this->_productRepository->get($id);
}
}
class ProductService
{
public function getProduct($id)
{
if (!$this->_productRepository->has($id)) {
throw new NotFoundException();
}
return $this->_productRepository->get($id);
}
public function createProduct($id, $data)
{
$this->_productRepository->create($id, $data);
}
}
Command Query Responsibility Segregation
... see CQS