예제 #1
0
    public function testScoreEntity()
    {
        $entity = new Entity();
        $entity->setProfileImageUrl('https://pbs.twimg.com/profile_images/55875903/randomkitten_bigger.jpeg');
        $entity->setUserName('t_ishida');
        $entity->setUrl('https://twitter.com/t_ishida/status/677131650585640960');
        $entity->setBody('怒首領蜂一面番長
ステージ1~2(全2面)
ファイター=Type-A(朱里)
難易度=特攻隊長(Hard)
Score=4918110点
 https://t.co/Ojz2Hse28r https://t.co/btKIBBa5HT');
        $entity->setSubject($entity->getBody());
        $score = new Score($entity);
        $this->assertInstanceOf('\\DDP\\GangLeader\\Score', $score);
        $this->assertSame('1~2(全2面)', $score->getStage());
        $this->assertSame('特攻隊長(Hard)', $score->getDifficulty());
        $this->assertSame('4918110', $score->getScore());
        $this->assertSame('t_ishida', $score->getUserName());
        $this->assertSame('https://pbs.twimg.com/profile_images/55875903/randomkitten_bigger.jpeg', $score->getProfileImageUrl());
        $this->assertSame('https://twitter.com/t_ishida/status/677131650585640960', $score->getUrl());
        $this->assertSame('怒首領蜂一面番長
ステージ1~2(全2面)
ファイター=Type-A(朱里)
難易度=特攻隊長(Hard)
Score=4918110点
 https://t.co/Ojz2Hse28r https://t.co/btKIBBa5HT', $score->getBody());
        $this->assertSame('怒首領蜂一面番長
ステージ1~2(全2面)
ファイター=Type-A(朱里)
難易度=特攻隊長(Hard)
Score=4918110点
 https://t.co/Ojz2Hse28r https://t.co/btKIBBa5HT', $score->getSubject());
    }
예제 #2
0
파일: Entity.php 프로젝트: t-ishida/Moshas
 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;
 }
예제 #3
0
파일: Score.php 프로젝트: t-ishida/Moshas
 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());
     }
 }
예제 #4
0
 public function run()
 {
     $maxId = null;
     $result = array();
     $limit = $this->getLimit();
     while (true) {
         $page = $this->client->get($this->buildUrl(), $this->buildQuery($maxId));
         if (!$page->statuses || count($result) >= $limit) {
             break;
         }
         foreach ($page->statuses as $row) {
             $entity = new Entity();
             $entity->setBody($row->text);
             $entity->setSubject($row->text);
             $entity->setCreatedAt($row->created_at);
             $entity->setUserName($row->user->screen_name);
             $entity->setProfileImageUrl($row->user->profile_image_url_https);
             $entity->setUrl('https://twitter.com/' . urlencode($row->user->screen_name) . '/statuses/' . urlencode($row->id));
             $result[] = $entity;
             $maxId = intval($row->id_str) - 1;
         }
     }
     return $result;
 }