Skip to content

Commit

Permalink
Added PhpDoc comments to Application classes
Browse files Browse the repository at this point in the history
  • Loading branch information
owenvoke committed Oct 17, 2017
1 parent fa85fb4 commit 576df57
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 5 deletions.
59 changes: 56 additions & 3 deletions src/YeTii/Applications/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,40 @@

namespace YeTii\Applications;

/**
* Class Curl
*/
class Curl
{

/**
* @var resource
*/
protected $ch;
/**
* @var string
*/
protected $responseHeader;
/**
* @var string
*/
protected $responseBody;
/**
* @var string
*/
protected $error;
/**
* @var int
*/
protected $httpCode;
/**
* @var float
*/
protected $latency;

/**
* Curl constructor.
* @param string|null $url
*/
public function __construct($url = null)
{
$this->ch = curl_init($url);
Expand All @@ -25,6 +49,11 @@ public function __construct($url = null)
curl_setopt($this->ch, CURLOPT_HEADER, true);
}

/**
* @param $name
* @param $arguments
* @return $this|mixed
*/
public function __call($name, $arguments)
{
if (method_exists($this, $name)) {
Expand All @@ -36,18 +65,29 @@ public function __call($name, $arguments)
}
}

/**
* @param $name
* @param $arguments
* @return mixed
*/
public static function __callStatic($name, $arguments)
{
$c = new Curl();

return call_user_func_array([$c, $name], $arguments);
}

/**
* @return mixed
*/
public function __toString()
{
return $this->response();
}

/**
* @return $this
*/
private function execute()
{
$latency = 0;
Expand All @@ -66,30 +106,43 @@ private function execute()
return $this;
}

/**
* @return mixed
*/
private function response()
{
return $this->responseBody;
}

/**
* @return mixed
*/
private function header()
{
return $this->responseHeader;
}

/**
* @return mixed
*/
private function error()
{
return $this->error;
}

/**
* @return mixed
*/
private function httpCode()
{
return $this->httpCode;
}

/**
* @return mixed
*/
private function latency()
{
return $this->latency;
}


}
53 changes: 51 additions & 2 deletions src/YeTii/Applications/Ffmpeg.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,42 @@
*/
class Ffmpeg
{

/**
* @var string
*/
protected $format = 'mp4';
/**
* @var string
*/
protected $ffmpeg_dir = '/usr/local/bin/ffmpeg';
/**
* @var int
*/
protected $delete_original = 0;

/**
* @var string
*/
protected $input;
/**
* @var string
*/
protected $output;

/**
* @var string
*/
protected $error;

/**
* @var array
*/
private $formats_available = ['mp4', 'mkv', 'avi', 'm4v', 'mpg', 'flv'];

/**
* Ffmpeg constructor.
* @param array $args
*/
public function __construct(array $args = [])
{
if (isset($args['format'])) {
Expand All @@ -35,6 +59,10 @@ public function __construct(array $args = [])
}
}

/**
* @param null $value
* @return $this|bool
*/
public function format($value = null)
{
if (!in_array($value, $this->formats_available)) {
Expand All @@ -47,6 +75,10 @@ public function format($value = null)
return $this;
}

/**
* @param null $value
* @return $this|bool
*/
public function ffmpeg_dir($value = null)
{
if (!file_exists($value)) {
Expand All @@ -59,13 +91,21 @@ public function ffmpeg_dir($value = null)
return $this;
}

/**
* @param null $value
* @return $this
*/
public function delete_original($value = null)
{
$this->delete_original = $value ? 1 : 0;

return $this;
}

/**
* @param FileStructure|null $value
* @return $this|bool
*/
public function from(FileStructure $value = null)
{
if (!$value->exists()) {
Expand All @@ -78,6 +118,10 @@ public function from(FileStructure $value = null)
return $this;
}

/**
* @param FileStructure|null $value
* @return $this|bool
*/
public function to(FileStructure $value = null)
{
if ($ext = $value->getExt()) {
Expand All @@ -95,6 +139,9 @@ public function to(FileStructure $value = null)
return $this;
}

/**
* @return bool
*/
private function ready()
{
if ($this->error) {
Expand All @@ -112,6 +159,9 @@ private function ready()
return true;
}

/**
* @return bool|null
*/
public function mux()
{
if (!$this->ready()) {
Expand All @@ -131,5 +181,4 @@ public function mux()

return preg_match('/video:/', $str) ? true : false;
}

}

0 comments on commit 576df57

Please sign in to comment.