<?php
namespace Sq\Entity\Schema\ORM;
use Doctrine\ORM\Mapping as ORM;
/**
* Snippet.
*/
#[ORM\Entity]
#[ORM\Table(name: 'snippet')]
class Snippet implements BelongsToWorkspaceInterface
{
#[ORM\Column(name: 'snip_id', type: 'integer', nullable: false, options: ['unsigned' => true])]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private ?int $id;
#[ORM\Column(name: 'snip_name', type: 'string', length: 255, nullable: true)]
private string $name;
#[ORM\Column(name: 'snip_content', type: 'string', length: 2200, nullable: true)]
private string $content;
#[ORM\ManyToOne(targetEntity: Member::class)]
#[ORM\JoinColumn(name: 'snip_m_id', referencedColumnName: 'm_id', nullable: true)]
private ?Member $member;
#[ORM\ManyToOne(targetEntity: Workspace::class, inversedBy: 'snippets')]
#[ORM\JoinColumn(name: 'snip_ws_id', referencedColumnName: 'ws_id', nullable: true)]
private ?Workspace $workspace;
public function __construct(Workspace $workspace, string $name, string $content)
{
$this->name = trim($name);
$this->content = trim($content);
$this->workspace = $workspace;
}
public function getId(): ?int
{
return $this->id;
}
public function getMember(): Member
{
return $this->member;
}
public function setMember(Member $member): self
{
$this->member = $member;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): void
{
$this->name = trim($name);
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = trim($content);
return $this;
}
public function getWorkspace(): Workspace
{
return $this->workspace;
}
public function isLegacyWithoutWorkspace(): bool
{
return $this->workspace === null;
}
}