/** * @param File $file * @return static */ public static function fromFile(File $file) { $note = new static(); $note->setId($file->getId()); $note->setContent($file->getContent()); $note->setModified($file->getMTime()); $note->setTitle(substr($file->getName(), 0, -4)); // remove trailing .txt $note->resetUpdatedFields(); return $note; }
/** * Maps the keys of the row array to the attributes * @param array $row the row to map onto the entity */ public static function fromRow(array $row) { $instance = new static(); foreach ($row as $key => $value) { $prop = ucfirst($instance->columnToProperty($key)); $setter = 'set' . $prop; $instance->{$setter}($value); } $instance->resetUpdatedFields(); return $instance; }
/** * @param File $file * @return static */ public static function fromFile(File $file) { $note = new static(); $note->setId($file->getId()); $note->setContent($file->getContent()); $note->setModified($file->getMTime()); $note->setTitle(pathinfo($file->getName(), PATHINFO_FILENAME)); // remove extension $note->resetUpdatedFields(); return $note; }