Witam,
Piszę API w Symfony 4. Znajomy mi napisał, że mam anemiczną encję, możecie mi wyjaśnić co to znaczy i jak zrobić encję, aby nie była anemiczna? Kod encji
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints
as Assert;/**
* @ORM\Entity(repositoryClass="App\Repository\PostRepository")
*/
class Post
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
*/
private $title;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
*/
private $content;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
*/
private $author;
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getAuthor(): ?string
{
return $this->author;
}
public function setAuthor(string $author): self
{
$this->author = $author;
return $this;
}
}
Chcę napisać prosty CRUD, ale taki który ma jakość, a nie byle bałagan bez dobrych praktyk i standardów, dlatego już teraz chciałbym uniknąć anemicznych encji.