Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds an AbstractBase class traited with PSR3's LoggerAwareTrait #2

Merged
merged 1 commit into from
Sep 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/JimLind/TiVo/AbstractBase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace JimLind\TiVo;

use Psr\Log\LoggerAwareTrait;
use Psr\Log\NullLogger;

abstract class AbstractBase
{
use LoggerAwareTrait;

public function __construct()
{
$this->logger = new NullLogger();
}

}
22 changes: 3 additions & 19 deletions src/JimLind/TiVo/TiVoFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,28 @@

namespace JimLind\TiVo;

use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;

/**
* Service for finding a TiVo on your local network
*/
class TiVoFinder
class TiVoFinder extends AbstractBase
{

/**
* @var ProcessBuilder
*/
protected $builder;

/**
* @var LoggerInterface
*/
protected $logger;

/**
* @param ProcessBuilder $builder The Symfony ProcessBuilder component
*/
public function __construct(ProcessBuilder $builder)
{
$this->builder = $builder;

// Default to the NullLogger
$this->setLogger(new NullLogger());
}

/**
*
* @param LoggerInterface $logger
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
parent::__construct();
}

/**
Expand Down
21 changes: 3 additions & 18 deletions src/JimLind/TiVo/VideoDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace JimLind\TiVo;

use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\Process\ProcessBuilder;

/**
* Service for decoding encoded TiVo video files
*/
class VideoDecoder
class VideoDecoder extends AbstractBase
{

/**
* @var string
*/
Expand All @@ -21,11 +20,6 @@ class VideoDecoder
*/
protected $builder;

/**
* @var LoggerInterface
*/
protected $logger;

/**
* @param string $mak Your TiVo's Media Access Key
* @param ProcessBuilder $builder The Symfony ProcessBuilder component
Expand All @@ -35,16 +29,7 @@ public function __construct($mak, ProcessBuilder $builder)
$this->mak = $mak;
$this->builder = $builder;

// Default to the NullLogger
$this->setLogger(new NullLogger());
}

/**
* @param LoggerInterface $logger
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
parent::__construct();
}

/**
Expand Down
21 changes: 3 additions & 18 deletions src/JimLind/TiVo/VideoDownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Cookie\CookieJar;
use GuzzleHttp\Exception\RequestException;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;

/**
* Service for downloading video files from a TiVo
*/
class VideoDownloader
class VideoDownloader extends AbstractBase
{

/**
* @var string
*/
Expand All @@ -23,11 +22,6 @@ class VideoDownloader
*/
protected $guzzle;

/**
* @var LoggerInterface
*/
protected $logger;

/**
* @param string $mak Your TiVo's Media Access Key
* @param ClientInterface $guzzle A Guzzle Client
Expand All @@ -37,16 +31,7 @@ public function __construct($mak, ClientInterface $guzzle)
$this->mak = $mak;
$this->guzzle = $guzzle;

// Default to the NullLogger
$this->setLogger(new NullLogger());
}

/**
* @param LoggerInterface $logger
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
parent::__construct();
}

/**
Expand Down
20 changes: 2 additions & 18 deletions src/JimLind/TiVo/XmlDownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
use GuzzleHttp\Psr7\Uri;
use JimLind\TiVo\Characteristic\XmlTrait;
use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use SimpleXMLElement;

/**
* Service for downloading a list of shows from a TiVo
*/
class XmlDownloader
class XmlDownloader extends AbstractBase
{
use XmlTrait;

Expand All @@ -36,11 +34,6 @@ class XmlDownloader
*/
protected $guzzle;

/**
* @var LoggerInterface
*/
protected $logger;

/**
* @param string $ip Your TiVo's IP Address
* @param string $mak Your TiVo's Media Access Key
Expand All @@ -56,16 +49,7 @@ public function __construct($ip, $mak, ClientInterface $guzzle)
$this->mak = $mak;
$this->guzzle = $guzzle;

// Default to the NullLogger
$this->setLogger(new NullLogger());
}

/**
* @param LoggerInterface $logger
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
parent::__construct();
}

/**
Expand Down