/** * @param Diagram $diagram * @throws \InvalidArgumentException if the diagram isn't valid */ public function save(Diagram $diagram) { if (!$diagram->isValid()) { throw new \InvalidArgumentException('Diagram is not valid'); } $this->database->save($diagram); }
public function populateDiagram(Diagram $diagram) { $diagram->setUmls($this->getUmls()); try { $diagram->setName($this->getName()); } catch (\InvalidArgumentException $e) { $length = $e->getMessage(); switch ($e->getCode()) { case Diagram::TOO_SHORT: $this->addError("The name is too short, a minimum of {$length} characters is required"); break; case Diagram::TOO_LONG: $this->addError("The name is too long, a maximum of {$length} characters is required"); break; } } }
public function __construct(Diagram $diagram) { $this->name = $diagram->getName(); $this->id = $diagram->getId(); $this->url = Router::FILE . '?' . FileView::RV_UMLS . '=' . rawurlencode($diagram->getUmls()); }