From bd34e94bbc48a2fb2aeb643866996ebd3a858844 Mon Sep 17 00:00:00 2001 From: jmleroux Date: Fri, 23 Sep 2016 18:12:02 +0200 Subject: [PATCH] Update PHPDoc --- .../TwitterExtractor/AppBundle/AppBundle.php | 6 ++++++ .../AppBundle/Command/InstallCommand.php | 13 ++++++------ .../AppBundle/Command/TwitterStoreCommand.php | 12 ++++++++++- .../DependencyInjection/AppExtension.php | 12 +++-------- .../Repository/TwitterRepository.php | 21 ++++++++++++++++++- .../Core/RepositoryInterface.php | 4 +++- src/Jmleroux/TwitterExtractor/Core/Saver.php | 3 +++ .../TwitterExtractor/Core/TwitterReader.php | 18 ++++++++++++++++ 8 files changed, 70 insertions(+), 19 deletions(-) diff --git a/src/Jmleroux/TwitterExtractor/AppBundle/AppBundle.php b/src/Jmleroux/TwitterExtractor/AppBundle/AppBundle.php index 49c4ef9..e7448a2 100644 --- a/src/Jmleroux/TwitterExtractor/AppBundle/AppBundle.php +++ b/src/Jmleroux/TwitterExtractor/AppBundle/AppBundle.php @@ -7,8 +7,14 @@ use Symfony\Component\Console\Application; use Symfony\Component\HttpKernel\Bundle\Bundle; +/** + * @author JM Leroux + */ class AppBundle extends Bundle { + /** + * {@inheritdoc} + */ public function registerCommands(Application $application) { $application->add(new InstallCommand()); diff --git a/src/Jmleroux/TwitterExtractor/AppBundle/Command/InstallCommand.php b/src/Jmleroux/TwitterExtractor/AppBundle/Command/InstallCommand.php index 9c5f080..98b725a 100644 --- a/src/Jmleroux/TwitterExtractor/AppBundle/Command/InstallCommand.php +++ b/src/Jmleroux/TwitterExtractor/AppBundle/Command/InstallCommand.php @@ -4,21 +4,21 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Schema\Schema; -use Jmleroux\TwitterExtractor\Core\TwitterReader; -use Jmleroux\TwitterExtractor\Core\Saver; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** * Store raw tweets in database. - * This command should be run in a cron to regularly strore new tweets. - * @author JM Leroux + * This command should be run in a cron to regularly store new tweets. + * + * @author JM Leroux */ class InstallCommand extends ContainerAwareCommand { + /** + * {@inheritdoc} + */ protected function configure() { $this->setName('jmleroux:twitter_extractor:install'); @@ -30,7 +30,6 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { - $database = $this->getContainer()->getParameter('database_name'); $command = $this->getApplication()->find('doctrine:database:create'); $command->run($input, $output); diff --git a/src/Jmleroux/TwitterExtractor/AppBundle/Command/TwitterStoreCommand.php b/src/Jmleroux/TwitterExtractor/AppBundle/Command/TwitterStoreCommand.php index 2cd3a96..ce703d1 100644 --- a/src/Jmleroux/TwitterExtractor/AppBundle/Command/TwitterStoreCommand.php +++ b/src/Jmleroux/TwitterExtractor/AppBundle/Command/TwitterStoreCommand.php @@ -12,10 +12,14 @@ /** * Store raw tweets in database. * This command should be run in a cron to regularly strore new tweets. - * @author JM Leroux + * + * @author JM Leroux */ class TwitterStoreCommand extends ContainerAwareCommand { + /** + * {@inheritdoc} + */ protected function configure() { $this->setName('jmleroux:twitter:extract'); @@ -61,6 +65,12 @@ private function getTwitterSaver() return $this->getContainer()->get('jmleroux.twitter_extractor.saver'); } + /** + * Write to console output and logger + * + * @param OutputInterface $output + * @param string $message + */ private function write(OutputInterface $output, $message) { $output->writeln($message); diff --git a/src/Jmleroux/TwitterExtractor/AppBundle/DependencyInjection/AppExtension.php b/src/Jmleroux/TwitterExtractor/AppBundle/DependencyInjection/AppExtension.php index 21ca5f4..aec3445 100644 --- a/src/Jmleroux/TwitterExtractor/AppBundle/DependencyInjection/AppExtension.php +++ b/src/Jmleroux/TwitterExtractor/AppBundle/DependencyInjection/AppExtension.php @@ -1,14 +1,5 @@ + */ class AppExtension extends Extension { /** diff --git a/src/Jmleroux/TwitterExtractor/AppBundle/Repository/TwitterRepository.php b/src/Jmleroux/TwitterExtractor/AppBundle/Repository/TwitterRepository.php index 7a41c06..5b4534c 100644 --- a/src/Jmleroux/TwitterExtractor/AppBundle/Repository/TwitterRepository.php +++ b/src/Jmleroux/TwitterExtractor/AppBundle/Repository/TwitterRepository.php @@ -5,6 +5,9 @@ use Doctrine\DBAL\Connection; use Jmleroux\TwitterExtractor\Core\RepositoryInterface; +/** + * @author JM Leroux + */ class TwitterRepository implements RepositoryInterface { /** @@ -16,12 +19,23 @@ class TwitterRepository implements RepositoryInterface */ private $tablename; + /** + * TwitterRepository constructor. + * + * @param Connection $dbal + * @param string $tablename + */ public function __construct(Connection $dbal, $tablename) { $this->dbal = $dbal; $this->tablename = $tablename; } + /** + * @param array $tweet + * + * @return \Doctrine\DBAL\Driver\Statement|int + */ public function save(array $tweet) { $qb = $this->dbal->createQueryBuilder(); @@ -33,12 +47,17 @@ public function save(array $tweet) return $qb->execute(); } + /** + * @param string $tweetId + * + * @return mixed|null + */ public function findById($tweetId) { $qb = $this->dbal->createQueryBuilder(); $qb->select('*') ->from($this->tablename) - ->where('id = :id')->setParameter(':id', $tweetId, \PDO::PARAM_INT); + ->where('id = :id')->setParameter(':id', $tweetId, \PDO::PARAM_STR); $result = $qb->execute()->fetch(); diff --git a/src/Jmleroux/TwitterExtractor/Core/RepositoryInterface.php b/src/Jmleroux/TwitterExtractor/Core/RepositoryInterface.php index 4d6ccaa..c273379 100644 --- a/src/Jmleroux/TwitterExtractor/Core/RepositoryInterface.php +++ b/src/Jmleroux/TwitterExtractor/Core/RepositoryInterface.php @@ -2,7 +2,9 @@ namespace Jmleroux\TwitterExtractor\Core; - +/** + * @author JM Leroux + */ interface RepositoryInterface { /** diff --git a/src/Jmleroux/TwitterExtractor/Core/Saver.php b/src/Jmleroux/TwitterExtractor/Core/Saver.php index f627b77..945b9b1 100644 --- a/src/Jmleroux/TwitterExtractor/Core/Saver.php +++ b/src/Jmleroux/TwitterExtractor/Core/Saver.php @@ -2,6 +2,9 @@ namespace Jmleroux\TwitterExtractor\Core; +/** + * @author JM Leroux + */ class Saver { /** diff --git a/src/Jmleroux/TwitterExtractor/Core/TwitterReader.php b/src/Jmleroux/TwitterExtractor/Core/TwitterReader.php index 62abbb9..2dba1bc 100644 --- a/src/Jmleroux/TwitterExtractor/Core/TwitterReader.php +++ b/src/Jmleroux/TwitterExtractor/Core/TwitterReader.php @@ -4,6 +4,9 @@ use TwitterAPIExchange; +/** + * @author JM Leroux + */ class TwitterReader { /** @@ -11,11 +14,21 @@ class TwitterReader */ protected $options; + /** + * TwitterReader constructor. + * + * @param array $options + */ public function __construct(array $options) { $this->options = $options; } + /** + * @param string[] $hastags + * + * @return array + */ public function searchTags(array $hastags) { $tweets = []; @@ -26,6 +39,11 @@ public function searchTags(array $hastags) return $tweets; } + /** + * @param string $search + * + * @return array + */ public function search($search) { $url = 'https://api.twitter.com/1.1/search/tweets.json';