This commit is contained in:
Chris
2018-10-18 15:59:38 +01:00
parent 4f6a0cb7c6
commit 380a0e8623
352 changed files with 32929 additions and 3604 deletions

View File

@@ -0,0 +1,32 @@
<?php
namespace Github\Exception;
/**
* ApiLimitExceedException.
*
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class ApiLimitExceedException extends RuntimeException
{
private $limit;
private $reset;
public function __construct($limit = 5000, $reset = 1800, $code = 0, $previous = null)
{
$this->limit = (int) $limit;
$this->reset = (int) $reset;
parent::__construct(sprintf('You have reached GitHub hourly limit! Actual limit is: %d', $limit), $code, $previous);
}
public function getLimit()
{
return $this->limit;
}
public function getResetTime()
{
return $this->reset;
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace Github\Exception;
/**
* BadMethodCallException.
*
* @author James Brooks <jbrooksuk@me.com>
*/
class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,12 @@
<?php
namespace Github\Exception;
/**
* ErrorException.
*
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class ErrorException extends \ErrorException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Github\Exception;
use Http\Client\Exception;
interface ExceptionInterface extends Exception
{
}

View File

@@ -0,0 +1,12 @@
<?php
namespace Github\Exception;
/**
* InvalidArgumentException.
*
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Github\Exception;
/**
* MissingArgumentException.
*
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class MissingArgumentException extends ErrorException
{
public function __construct($required, $code = 0, $previous = null)
{
if (is_string($required)) {
$required = [$required];
}
parent::__construct(sprintf('One or more of required ("%s") parameters is missing!', implode('", "', $required)), $code, $previous);
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace Github\Exception;
/**
* RuntimeException.
*
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Github\Exception;
class TwoFactorAuthenticationRequiredException extends RuntimeException
{
private $type;
public function __construct($type, $code = 0, $previous = null)
{
$this->type = $type;
parent::__construct('Two factor authentication is enabled on this account', $code, $previous);
}
public function getType()
{
return $this->type;
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace Github\Exception;
/**
* When GitHub returns with a HTTP response that says our request is invalid.
*
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class ValidationFailedException extends ErrorException
{
}