public function __construct(\Moshas\Entity $entity, array $words, $category = null) { $this->setSubject($entity->getSubject()); $this->setBody($entity->getBody()); $this->setUrl($entity->getUrl()); $this->setProfileImageUrl($entity->getProfileImageUrl()); $this->setUserName($entity->getUserName()); $this->words = $words; $this->original = $entity; $this->category = $category; }
public function __construct(Entity $entity = null) { if ($entity) { if (preg_match('#ステージ(\\S+).+?ファイター=(\\S+).+?難易度=(\\S+).+?Score=(\\d+)#msu', $entity->getBody(), $matches)) { $this->stage = $matches[1]; $this->fighter = $matches[2]; $this->difficulty = $matches[3]; $this->score = $matches[4]; } else { throw new \InvalidArgumentException('not score'); } $this->setUrl($entity->getUrl()); $this->setUserName($entity->getUserName()); $this->setBody($entity->getBody()); $this->setSubject($entity->getSubject()); $this->setCreatedAt($entity->getCreatedAt()); $this->setProfileImageUrl($entity->getProfileImageUrl()); } }