Skip to content

Commit

Permalink
Update PHPDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
jmleroux committed Sep 23, 2016
1 parent 2a7fcd6 commit bd34e94
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 19 deletions.
6 changes: 6 additions & 0 deletions src/Jmleroux/TwitterExtractor/AppBundle/AppBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
use Symfony\Component\Console\Application;
use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
* @author JM Leroux <jmleroux.pro@gmail.com>
*/
class AppBundle extends Bundle
{
/**
* {@inheritdoc}
*/
public function registerCommands(Application $application)
{
$application->add(new InstallCommand());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <jean-marie.leroux@akeneo.com>
* This command should be run in a cron to regularly store new tweets.
*
* @author JM Leroux <jmleroux.pro@gmail.com>
*/
class InstallCommand extends ContainerAwareCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this->setName('jmleroux:twitter_extractor:install');
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <jean-marie.leroux@akeneo.com>
*
* @author JM Leroux <jmleroux.pro@gmail.com>
*/
class TwitterStoreCommand extends ContainerAwareCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this->setName('jmleroux:twitter:extract');
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
<?php

/*
* This file is part of the Akeneo PIM Enterprise Edition.
*
* (c) 2014 Akeneo SAS (http://www.akeneo.com)
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Jmleroux\TwitterExtractor\AppBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
* @author JM Leroux <jmleroux.pro@gmail.com>
*/
class AppExtension extends Extension
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Doctrine\DBAL\Connection;
use Jmleroux\TwitterExtractor\Core\RepositoryInterface;

/**
* @author JM Leroux <jmleroux.pro@gmail.com>
*/
class TwitterRepository implements RepositoryInterface
{
/**
Expand All @@ -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();
Expand All @@ -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();

Expand Down
4 changes: 3 additions & 1 deletion src/Jmleroux/TwitterExtractor/Core/RepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Jmleroux\TwitterExtractor\Core;


/**
* @author JM Leroux <jmleroux.pro@gmail.com>
*/
interface RepositoryInterface
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Jmleroux/TwitterExtractor/Core/Saver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Jmleroux\TwitterExtractor\Core;

/**
* @author JM Leroux <jmleroux.pro@gmail.com>
*/
class Saver
{
/**
Expand Down
18 changes: 18 additions & 0 deletions src/Jmleroux/TwitterExtractor/Core/TwitterReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,31 @@

use TwitterAPIExchange;

/**
* @author JM Leroux <jmleroux.pro@gmail.com>
*/
class TwitterReader
{
/**
* @var string[]
*/
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 = [];
Expand All @@ -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';
Expand Down

0 comments on commit bd34e94

Please sign in to comment.