Issues (324)

src/Manager/Project/NewsManager.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace App\Manager\Project;
4
5
use Doctrine\ORM\EntityManagerInterface;
6
7
use App\Entity\Project\{
8
    Project,
9
    News
10
};
11
12
class NewsManager
13
{
14
    /** @var EntityManagerInterface **/
15
    protected $em;
16
    
17
    public function __construct(EntityManagerInterface $em)
18
    {
19
        $this->em = $em;
20
    }
21
    
22
    public function getProjectNews(Project $project): array
23
    {
24
        return $this->em->getRepository(News::class)->findByProject($project, ['createdAt' => 'DESC']);
0 ignored issues
show
The method findByProject() does not exist on App\Repository\Project\NewsRepository. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        return $this->em->getRepository(News::class)->/** @scrutinizer ignore-call */ findByProject($project, ['createdAt' => 'DESC']);
Loading history...
25
    }
26
    
27
    public function create(Project $project, string $category, array $data): News
28
    {
29
        $news =
30
            (new News())
31
            ->setProject($project)
32
            ->setCategory($category)
33
            ->setData($data)
34
        ;
35
        $this->em->persist($news);
36
        $this->em->flush();
37
        return $news;
38
    }
39
}