コード例 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $commit = $input->getOption('commit');
     // Figure this out for new ones
     $loneliness = Loneliness::fromInteger(0);
     /** @var ContainerInterface $container */
     $container = $this->getContainer();
     /** @var PullRequestsRepository $pullRequestRepository */
     $pullRequestRepository = $container->get('lonely_pull_requests.repository.pull_requests');
     /** @var NotificationRepository $notificationRepository */
     $notificationRepository = $container->get('lonely_pull_requests.repository.notification');
     $lastEventDateTime = null;
     // Parse notifications for new pull requests
     $notifications = $notificationRepository->all();
     foreach ($notifications as $notification) {
         $output->writeln('Parsing notification for URL: ' . $notification->url()->toString());
         /** @var Notification $notification */
         $pullRequest = $notification->pullRequest($loneliness);
         $pullRequestRepository->add($pullRequest);
         // Update latest entry
         if ($lastEventDateTime === null || $notification->eventDateTime() > $lastEventDateTime) {
             $lastEventDateTime = $notification->eventDateTime();
         }
     }
     if ($commit && $lastEventDateTime !== null) {
         $notificationRepository->markRead($lastEventDateTime);
     }
 }
コード例 #2
0
 public static function fromArray(array $array)
 {
     Ensure::keyExists($array, 'title');
     Ensure::keyExists($array, 'repositoryName');
     Ensure::keyExists($array, 'url');
     Ensure::keyExists($array, 'loneliness');
     return self::create(Title::fromString($array['title']), RepositoryName::fromString($array['repositoryName']), Url::fromString($array['url']), Loneliness::fromInteger($array['loneliness']));
 }
コード例 #3
0
 public function testConvertToDatabaseValue()
 {
     $lonelinessScore = 42;
     $loneliness = Loneliness::fromInteger($lonelinessScore);
     $databaseValue = $this->type->convertToDatabaseValue($loneliness, $this->platform);
     $this->assertTrue(gettype($databaseValue) === 'integer');
     $this->assertSame($databaseValue, $lonelinessScore);
 }
コード例 #4
0
 /**
  * Testing toString methods and assert no mutation
  */
 public function testToString()
 {
     $lonelinessScore = 42;
     $loneliness = Loneliness::fromInteger($lonelinessScore);
     // String casting
     $stringCastedLoneliness = (string) $loneliness;
     $this->assertEquals($lonelinessScore, $stringCastedLoneliness);
     $this->assertTrue(gettype($stringCastedLoneliness) === 'string');
     // String converted
     $stringConvertedLoneliness = $loneliness->toString();
     $this->assertEquals($lonelinessScore, $stringConvertedLoneliness);
     $this->assertTrue(gettype($stringConvertedLoneliness) === 'string');
     // String converted
     $integerConvertedLoneliness = $loneliness->toInteger();
     $this->assertEquals($lonelinessScore, $integerConvertedLoneliness);
     $this->assertTrue(gettype($integerConvertedLoneliness) === 'integer');
 }
コード例 #5
0
 /**
  * Converts a value from its PHP representation to its database representation
  * of this type.
  *
  * @param Loneliness                                $value    The value to convert.
  * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform The currently used database platform.
  *
  * @return int The database representation of the value.
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     /** @var \LonelyPullRequests\Domain\Loneliness $value */
     return $value->toInteger();
 }