repo stringlengths 7 63 | file_url stringlengths 81 284 | file_path stringlengths 5 200 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:02:33 2026-01-05 05:24:06 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
adamgriffiths/ag-auth | https://github.com/adamgriffiths/ag-auth/blob/5e83e14f80fe7ab71a682b27f0ea014c9c10690b/config/ag_auth.php | config/ag_auth.php | <?php
/**
* Authentication Library
*
* @package Authentication
* @category Libraries
* @author Adam Griffiths
* @link http://adamgriffiths.co.uk
* @version 1.0.6
* @copyright Adam Griffiths 2009
*
* Auth provides a powerful, lightweight and simple interface for user authentication
*/
/**
* The array which holds your user groups and their ID.
* If you have a database table for groups, these ID's must be the same as in the database.
*/
$config['auth_groups'] = array(
'admin' => '1',
'editor' => '2',
'user' => '100'
);
/**
* The default URI string to redirect to after a successful login.
*/
$config['auth_login'] = 'admin/dashboard';
/**
* The default URI string to redirect to after a successful logout.
*/
$config['auth_logout'] = 'login';
/**
* The URI string to redirect to when a user entered incorrect login details or is not authenticated
*/
$config['auth_incorrect_login'] = 'login';
/**
* bool TRUE / FALSE
* Determines whether or not users will be remembered by the auth library
*/
$config['auth_remember'] = TRUE;
/**
* The following options provide the ability to easily rename the directories
* for your auth views, models, and controllers.
*
* Remember to also update your routes file if you change the controller directory
* MUST HAVE A TRAILING SLASH!
*/
$config['auth_controllers_root'] = 'admin/';
$config['auth_models_root'] = '';
$config['auth_views_root'] = 'auth/';
/**
* Set the names for your user tables below (sans prefix, which will be automatically added)
* ex.: your table is named `ci_users` with 'ci_' defined as your dbprefix in config/database.php, so set it to 'users' below
*/
$config['auth_user_table'] = 'users';
$config['auth_group_table'] = 'groups';
?> | php | MIT | 5e83e14f80fe7ab71a682b27f0ea014c9c10690b | 2026-01-05T04:39:19.688431Z | false |
adamgriffiths/ag-auth | https://github.com/adamgriffiths/ag-auth/blob/5e83e14f80fe7ab71a682b27f0ea014c9c10690b/language/english/auth_lang.php | language/english/auth_lang.php | <?php
/**
* Authentication Library
*
* @package Authentication
* @category Libraries
* @author Adam Griffiths
* @link http://programmersvoice.com
* @version 1.0.4
* @copyright Adam Griffiths 2009
*
* Auth provides a powerful, lightweight and simple interface for user authentication
*/
$lang['insufficient_privs'] = "You do not have sufficient privileges to access this page.";
$lang['username_callback_error'] = "The username was not found in our database.";
$lang['reg_username_callback_error'] = "The username is in use, please select another username.";
$lang['reg_email_callback_error'] = "The email is in use, please select another email.";
$lang['login_details_error'] = "The username and password did not match our records, please try again.";
$lang['max_login_attempts_error'] = "You have exceeded your maximum number of attempted logins, if you have forgotten your password, please consult the lost password form. You will be able to login again in 15 minutes.";
$lang['logout_perms_error'] = "You have been logged out due to a permission error, please login again.";
?> | php | MIT | 5e83e14f80fe7ab71a682b27f0ea014c9c10690b | 2026-01-05T04:39:19.688431Z | false |
adamgriffiths/ag-auth | https://github.com/adamgriffiths/ag-auth/blob/5e83e14f80fe7ab71a682b27f0ea014c9c10690b/language/english/ag_auth_lang.php | language/english/ag_auth_lang.php | <?php
/**
* Authentication Library
*
* @package Authentication
* @category Libraries
* @author Adam Griffiths
* @link http://programmersvoice.com
* @version 1.0.4
* @copyright Adam Griffiths 2009
*
* Auth provides a powerful, lightweight and simple interface for user authentication
*/
$lang['insufficient_privs'] = "You do not have sufficient privileges to access this page.";
$lang['username_callback_error'] = "The username was not found in our database.";
$lang['reg_username_callback_error'] = "The username is in use, please select another username.";
$lang['reg_email_callback_error'] = "The email is in use, please select another email.";
$lang['login_details_error'] = "The username and password did not match our records, please try again.";
$lang['max_login_attempts_error'] = "You have exceeded your maximum number of attempted logins, if you have forgotten your password, please consult the lost password form. You will be able to login again in 15 minutes.";
$lang['logout_perms_error'] = "You have been logged out due to a permission error, please login again.";
?> | php | MIT | 5e83e14f80fe7ab71a682b27f0ea014c9c10690b | 2026-01-05T04:39:19.688431Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/.php-cs-fixer.php | .php-cs-fixer.php | <?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('vendor')
;
return (new PhpCsFixer\Config())
->setFinder($finder)
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'declare_strict_types' => true,
'return_type_declaration' => ['space_before' => 'none'],
'phpdoc_line_span' => ['property' => 'single'],
]);
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Version.php | src/Version.php | <?php
declare(strict_types=1);
namespace Version;
use JsonSerializable;
use Version\Assert\VersionAssert;
use Version\Extension\Build;
use Version\Exception\InvalidVersionString;
use Version\Comparison\Comparator;
use Version\Comparison\SemverComparator;
use Version\Comparison\Constraint\Constraint;
use Version\Extension\PreRelease;
class Version implements JsonSerializable
{
public const REGEX = '#^(?P<prefix>v|release\-)?(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:\-(?P<preRelease>(?:0|[1-9]\d*|\d*[a-zA-Z\-][0-9a-zA-Z\-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z\-][0-9a-zA-Z\-]*))*))?(?:\+(?P<build>[0-9a-zA-Z\-]+(?:\.[0-9a-zA-Z\-]+)*))?$#';
protected int $major;
protected int $minor;
protected int $patch;
protected ?PreRelease $preRelease;
protected ?Build $build;
protected string $prefix = '';
protected static ?Comparator $comparator = null;
final protected function __construct(int $major, int $minor, int $patch, ?PreRelease $preRelease = null, ?Build $build = null)
{
VersionAssert::that($major)->greaterOrEqualThan(0, 'Major version must be positive integer');
VersionAssert::that($minor)->greaterOrEqualThan(0, 'Minor version must be positive integer');
VersionAssert::that($patch)->greaterOrEqualThan(0, 'Patch version must be positive integer');
$this->major = $major;
$this->minor = $minor;
$this->patch = $patch;
$this->preRelease = $preRelease;
$this->build = $build;
}
public static function from(int $major, int $minor = 0, int $patch = 0, ?PreRelease $preRelease = null, ?Build $build = null): Version
{
return new static($major, $minor, $patch, $preRelease, $build);
}
/**
* @throws InvalidVersionString
*/
public static function fromString(string $versionString): Version
{
if (!preg_match(self::REGEX, $versionString, $parts)) {
throw InvalidVersionString::notParsable($versionString);
}
$version = new static(
(int) $parts['major'],
(int) $parts['minor'],
(int) $parts['patch'],
(isset($parts['preRelease']) && '' !== $parts['preRelease']) ? PreRelease::fromString($parts['preRelease']) : null,
(isset($parts['build']) && '' !== $parts['build']) ? Build::fromString($parts['build']) : null
);
$version->prefix = $parts['prefix'] ?? '';
return $version;
}
public function getMajor(): int
{
return $this->major;
}
public function getMinor(): int
{
return $this->minor;
}
public function getPatch(): int
{
return $this->patch;
}
public function getPreRelease(): ?PreRelease
{
return $this->preRelease;
}
public function getBuild(): ?Build
{
return $this->build;
}
public function isEqualTo(Version|string $version): bool
{
return $this->compareTo($version) === 0;
}
public function isNotEqualTo(Version|string $version): bool
{
return !$this->isEqualTo($version);
}
public function isGreaterThan(Version|string $version): bool
{
return $this->compareTo($version) > 0;
}
public function isGreaterOrEqualTo(Version|string $version): bool
{
return $this->compareTo($version) >= 0;
}
public function isLessThan(Version|string $version): bool
{
return $this->compareTo($version) < 0;
}
public function isLessOrEqualTo(Version|string $version): bool
{
return $this->compareTo($version) <= 0;
}
/**
* @return int (1 if $this > $version, -1 if $this < $version, 0 if equal)
*/
public function compareTo(Version|string $version): int
{
if (is_string($version)) {
$version = static::fromString($version);
}
return $this->getComparator()->compare($this, $version);
}
public function isMajorRelease(): bool
{
return $this->major > 0 && $this->minor === 0 && $this->patch === 0;
}
public function isMinorRelease(): bool
{
return $this->minor > 0 && $this->patch === 0;
}
public function isPatchRelease(): bool
{
return $this->patch > 0;
}
public function isPreRelease(): bool
{
return $this->preRelease !== null;
}
public function hasBuild(): bool
{
return $this->build !== null;
}
public function incrementMajor(): Version
{
return new static($this->major + 1, 0, 0);
}
public function incrementMinor(): Version
{
return new static($this->major, $this->minor + 1, 0);
}
public function incrementPatch(): Version
{
return new static($this->major, $this->minor, $this->patch + 1);
}
public function withPreRelease(PreRelease|string|null $preRelease): Version
{
if (is_string($preRelease)) {
$preRelease = PreRelease::fromString($preRelease);
}
return new static($this->major, $this->minor, $this->patch, $preRelease);
}
public function withBuild(Build|string|null $build): Version
{
if (is_string($build)) {
$build = Build::fromString($build);
}
return new static($this->major, $this->minor, $this->patch, $this->preRelease, $build);
}
public function matches(Constraint $constraint): bool
{
return $constraint->assert($this);
}
public function toString(): string
{
return
$this->prefix
. $this->major
. '.' . $this->minor
. '.' . $this->patch
. (($this->preRelease !== null) ? '-' . $this->preRelease->toString() : '')
. (($this->build !== null) ? '+' . $this->build->toString() : '')
;
}
public function __toString(): string
{
return $this->toString();
}
public function jsonSerialize(): string
{
return $this->toString();
}
public function toArray(): array
{
return [
'major' => $this->major,
'minor' => $this->minor,
'patch' => $this->patch,
'preRelease' => ($this->preRelease !== null) ? $this->preRelease->getIdentifiers() : null,
'build' => ($this->build !== null) ? $this->build->getIdentifiers() : null,
];
}
public static function setComparator(?Comparator $comparator): void
{
static::$comparator = $comparator;
}
protected function getComparator(): Comparator
{
if (static::$comparator === null) {
static::$comparator = new SemverComparator();
}
return static::$comparator;
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/VersionCollection.php | src/VersionCollection.php | <?php
declare(strict_types=1);
namespace Version;
use Countable;
use IteratorAggregate;
use ArrayIterator;
use Traversable;
use Version\Comparison\Constraint\Constraint;
use Version\Exception\CollectionIsEmpty;
class VersionCollection implements Countable, IteratorAggregate
{
/** @var Version[] */
protected array $versions;
final public function __construct(Version ...$versions)
{
$this->versions = $versions;
}
public function count(): int
{
return count($this->versions);
}
public function isEmpty(): bool
{
return empty($this->versions);
}
public function first(): Version
{
if (empty($this->versions)) {
throw CollectionIsEmpty::cannotGetFirst();
}
return reset($this->versions);
}
public function last(): Version
{
if (empty($this->versions)) {
throw CollectionIsEmpty::cannotGetLast();
}
$version = end($this->versions);
reset($this->versions);
return $version;
}
public function getIterator(): Traversable
{
return new ArrayIterator($this->versions);
}
public function sortedAscending(): VersionCollection
{
$versions = $this->versions;
usort($versions, static function (Version $a, Version $b) {
return $a->compareTo($b);
});
return new static(...$versions);
}
public function sortedDescending(): VersionCollection
{
$versions = $this->versions;
usort($versions, static function (Version $a, Version $b) {
return $a->compareTo($b) * -1;
});
return new static(...$versions);
}
public function matching(Constraint $constraint): VersionCollection
{
return new static(...array_filter(
$this->versions,
static function (Version $version) use ($constraint) {
return $version->matches($constraint);
}
));
}
public function majorReleases(): VersionCollection
{
return new static(...array_filter(
$this->versions,
static function (Version $version) {
return $version->isMajorRelease();
}
));
}
public function minorReleases(): VersionCollection
{
return new static(...array_filter(
$this->versions,
static function (Version $version) {
return $version->isMinorRelease();
}
));
}
public function patchReleases(): VersionCollection
{
return new static(...array_filter(
$this->versions,
static function (Version $version) {
return $version->isPatchRelease();
}
));
}
/**
* @return Version[]
*/
public function toArray(): array
{
return $this->versions;
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Extension/Extension.php | src/Extension/Extension.php | <?php
declare(strict_types=1);
namespace Version\Extension;
use Version\Exception\InvalidVersion;
abstract class Extension
{
protected const IDENTIFIERS_SEPARATOR = '.';
private array $identifiers;
final protected function __construct(array $identifiers)
{
$this->validate($identifiers);
$this->identifiers = $identifiers;
}
/**
* @throws InvalidVersion
*/
abstract protected function validate(array $identifiers): void;
public static function from(string $identifier, string ...$identifiers): static
{
return new static(func_get_args());
}
public static function fromArray(array $identifiers): static
{
return new static($identifiers);
}
public static function fromString(string $extension): static
{
return new static(explode(self::IDENTIFIERS_SEPARATOR, trim($extension)));
}
public function getIdentifiers(): array
{
return $this->identifiers;
}
public function toString(): string
{
return implode(self::IDENTIFIERS_SEPARATOR, $this->identifiers);
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Extension/PreRelease.php | src/Extension/PreRelease.php | <?php
declare(strict_types=1);
namespace Version\Extension;
use Version\Assert\VersionAssert;
class PreRelease extends Extension
{
protected function validate(array $identifiers): void
{
VersionAssert::that($identifiers)
->minCount(1, 'Pre-release version must contain at least one identifier')
->all()
->regex('/^[0-9A-Za-z\-]+$/', 'Pre-release version identifiers can include only alphanumerics and hyphen');
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Extension/Build.php | src/Extension/Build.php | <?php
declare(strict_types=1);
namespace Version\Extension;
use Version\Assert\VersionAssert;
class Build extends Extension
{
protected function validate(array $identifiers): void
{
VersionAssert::that($identifiers)
->minCount(1, 'Build metadata must contain at least one identifier')
->all()
->regex('/^[0-9A-Za-z\-]+$/', 'Build metadata identifiers can include only alphanumerics and hyphen');
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Comparison/Comparator.php | src/Comparison/Comparator.php | <?php
declare(strict_types=1);
namespace Version\Comparison;
use Version\Version;
interface Comparator
{
public function compare(Version $version1, Version $version2): int;
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Comparison/SemverComparator.php | src/Comparison/SemverComparator.php | <?php
declare(strict_types=1);
namespace Version\Comparison;
use Version\Extension\PreRelease;
use Version\Version;
final class SemverComparator implements Comparator
{
public function compare(Version $version1, Version $version2): int
{
if (0 !== ($numberComparisonResult = $this->compareNumbers($version1, $version2))) {
return $numberComparisonResult;
}
if ($version1->isPreRelease() && $version2->isPreRelease()) {
return $this->comparePreReleases($version1->getPreRelease(), $version2->getPreRelease());
}
return $this->resolvePreReleasePrecedence($version1, $version2);
}
private function compareNumbers(Version $version1, Version $version2): int
{
return [$version1->getMajor(), $version1->getMinor(), $version1->getPatch()] <=> [$version2->getMajor(), $version2->getMinor(), $version2->getPatch()];
}
private function comparePreReleases(PreRelease $preRelease1, PreRelease $preRelease2): int
{
$preRelease1Ids = $preRelease1->getIdentifiers();
$preRelease2Ids = $preRelease2->getIdentifiers();
$preRelease1IdsCount = count($preRelease1Ids);
$preRelease2IdsCount = count($preRelease2Ids);
$limit = min($preRelease1IdsCount, $preRelease2IdsCount);
for ($i = 0; $i < $limit; $i++) {
if ($preRelease1Ids[$i] === $preRelease2Ids[$i]) {
continue;
}
return $preRelease1Ids[$i] <=> $preRelease2Ids[$i];
}
return $preRelease1IdsCount - $preRelease2IdsCount;
}
private function resolvePreReleasePrecedence(Version $version1, Version $version2): int
{
//pre-release version has lower precedence than a normal version
return -1 * ($version1->isPreRelease() <=> $version2->isPreRelease());
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Comparison/Exception/InvalidOperationConstraint.php | src/Comparison/Exception/InvalidOperationConstraint.php | <?php
declare(strict_types=1);
namespace Version\Comparison\Exception;
use InvalidArgumentException;
use Version\Exception\VersionException;
class InvalidOperationConstraint extends InvalidArgumentException implements VersionComparisonException
{
public static function unsupportedOperator(string $operator): self
{
return new self(sprintf('Unsupported constraint operator: %s', $operator));
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Comparison/Exception/VersionComparisonException.php | src/Comparison/Exception/VersionComparisonException.php | <?php
declare(strict_types=1);
namespace Version\Comparison\Exception;
use Version\Exception\VersionException;
interface VersionComparisonException extends VersionException
{
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Comparison/Exception/InvalidCompositeConstraint.php | src/Comparison/Exception/InvalidCompositeConstraint.php | <?php
declare(strict_types=1);
namespace Version\Comparison\Exception;
use InvalidArgumentException;
use Version\Exception\VersionException;
class InvalidCompositeConstraint extends InvalidArgumentException implements VersionComparisonException
{
public static function unsupportedOperator(string $operator): self
{
return new self(sprintf('Unsupported composite constraint operator: %s', $operator));
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Comparison/Exception/InvalidConstraintString.php | src/Comparison/Exception/InvalidConstraintString.php | <?php
declare(strict_types=1);
namespace Version\Comparison\Exception;
use InvalidArgumentException;
use Version\Exception\VersionException;
class InvalidConstraintString extends InvalidArgumentException implements VersionComparisonException
{
public static function empty(): self
{
return new self('Comparison constraint string must not be empty');
}
public static function notParsable(string $constraintString): self
{
return new self(sprintf(
"Comparison constraint string: '%s' is not valid and cannot be parsed",
$constraintString
));
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Comparison/Constraint/OperationConstraintParser.php | src/Comparison/Constraint/OperationConstraintParser.php | <?php
declare(strict_types=1);
namespace Version\Comparison\Constraint;
use Version\Exception\VersionException;
use Version\Comparison\Exception\InvalidConstraintString;
use Version\Version;
class OperationConstraintParser
{
public const OPERATOR_OR = '||';
protected string $constraintString;
protected array $constraintParts = [];
/**
* @return OperationConstraint|CompositeConstraint
*/
public function parse(string $constraintString)
{
$constraintString = trim($constraintString);
if ($constraintString === '') {
throw InvalidConstraintString::empty();
}
$this->constraintString = $constraintString;
if (!$this->isMultiPartConstraint()) {
return $this->buildConstraint($this->constraintString);
}
$this->splitConstraintParts();
return $this->buildCompositeConstraint();
}
protected function isMultiPartConstraint(): bool
{
return str_contains($this->constraintString, ' ');
}
protected function splitConstraintParts(): void
{
$constraintParts = explode(' ', $this->constraintString);
$this->constraintParts = array_map('trim', $constraintParts);
}
protected function buildConstraint(string $constraintPart): OperationConstraint
{
[$operator, $operandString] = array_values($this->parseConstraint($constraintPart));
if (empty($operandString)) {
$this->error();
}
try {
return new OperationConstraint(
$operator ?: OperationConstraint::OPERATOR_EQ,
Version::fromString($operandString)
);
} catch (VersionException) {
$this->error();
}
}
protected function parseConstraint(string $constraintStringUnit): array
{
$i = 0;
while (isset($constraintStringUnit[$i]) && !ctype_digit($constraintStringUnit[$i])) {
$i++;
}
$operator = substr($constraintStringUnit, 0, $i);
$operand = substr($constraintStringUnit, $i);
return [
'operator' => $operator,
'operand' => $operand,
];
}
protected function buildCompositeConstraint(): CompositeConstraint
{
$compositeAndConstraints = $compositeOrConstraints = [];
foreach ($this->constraintParts as $constraintPart) {
if (self::OPERATOR_OR === $constraintPart) {
$compositeOrConstraints[] = CompositeConstraint::and(...$compositeAndConstraints);
$compositeAndConstraints = []; //reset collected AND constraints
} else {
$compositeAndConstraints[] = $this->buildConstraint($constraintPart);
}
}
if (!empty($compositeOrConstraints)) {
if (empty($compositeAndConstraints)) {
//invalid OR constraint; no right side
$this->error();
}
$compositeOrConstraints[] = CompositeConstraint::and(...$compositeAndConstraints);
return CompositeConstraint::or(...$compositeOrConstraints);
}
return CompositeConstraint::and(...$compositeAndConstraints);
}
protected function error(): void
{
throw InvalidConstraintString::notParsable($this->constraintString);
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Comparison/Constraint/Constraint.php | src/Comparison/Constraint/Constraint.php | <?php
declare(strict_types=1);
namespace Version\Comparison\Constraint;
use Version\Version;
interface Constraint
{
public function assert(Version $version): bool;
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Comparison/Constraint/OperationConstraint.php | src/Comparison/Constraint/OperationConstraint.php | <?php
declare(strict_types=1);
namespace Version\Comparison\Constraint;
use ReflectionClass;
use Version\Version;
use Version\Comparison\Exception\InvalidOperationConstraint;
class OperationConstraint implements Constraint
{
public const OPERATOR_EQ = '=';
public const OPERATOR_NEQ = '!=';
public const OPERATOR_GT = '>';
public const OPERATOR_GTE = '>=';
public const OPERATOR_LT = '<';
public const OPERATOR_LTE = '<=';
protected string $operator;
protected Version $operand;
final public function __construct(string $operator, Version $operand)
{
$this->validateOperator($operator);
$this->operator = $operator;
$this->operand = $operand;
}
public static function equalTo(Version $operand): static
{
return new static(self::OPERATOR_EQ, $operand);
}
public static function notEqualTo(Version $operand): static
{
return new static(self::OPERATOR_NEQ, $operand);
}
public static function greaterThan(Version $operand): static
{
return new static(self::OPERATOR_GT, $operand);
}
public static function greaterOrEqualTo(Version $operand): static
{
return new static(self::OPERATOR_GTE, $operand);
}
public static function lessThan(Version $operand): static
{
return new static(self::OPERATOR_LT, $operand);
}
public static function lessOrEqualTo(Version $operand): static
{
return new static(self::OPERATOR_LTE, $operand);
}
public static function fromString(string $constraintString): CompositeConstraint|OperationConstraint
{
static $parser = null;
if (null === $parser) {
$parser = new OperationConstraintParser();
}
return $parser->parse($constraintString);
}
public function getOperator(): string
{
return $this->operator;
}
public function getOperand(): Version
{
return $this->operand;
}
public function assert(Version $version): bool
{
return match ($this->operator) {
self::OPERATOR_EQ => $version->isEqualTo($this->operand),
self::OPERATOR_NEQ => !$version->isEqualTo($this->operand),
self::OPERATOR_GT => $version->isGreaterThan($this->operand),
self::OPERATOR_GTE => $version->isGreaterOrEqualTo($this->operand),
self::OPERATOR_LT => $version->isLessThan($this->operand),
self::OPERATOR_LTE => $version->isLessOrEqualTo($this->operand),
default => throw InvalidOperationConstraint::unsupportedOperator($this->operator),
};
}
protected function validateOperator(string $operator): void
{
static $validOperators = null;
if ($validOperators === null) {
$validOperators = (new ReflectionClass($this))->getConstants();
}
if (!in_array($operator, $validOperators, true)) {
throw InvalidOperationConstraint::unsupportedOperator($operator);
}
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Comparison/Constraint/CompositeConstraint.php | src/Comparison/Constraint/CompositeConstraint.php | <?php
declare(strict_types=1);
namespace Version\Comparison\Constraint;
use Version\Version;
use Version\Comparison\Exception\InvalidCompositeConstraint;
class CompositeConstraint implements Constraint
{
public const OPERATOR_AND = 'AND';
public const OPERATOR_OR = 'OR';
protected string $operator;
protected array $constraints;
final public function __construct(string $operator, Constraint $constraint, Constraint ...$constraints)
{
if (! in_array($operator, [self::OPERATOR_AND, self::OPERATOR_OR], true)) {
throw InvalidCompositeConstraint::unsupportedOperator($operator);
}
$this->operator = $operator;
$this->constraints = array_merge([$constraint], $constraints);
}
public static function and(Constraint $constraint, Constraint ...$constraints): CompositeConstraint
{
return new static(self::OPERATOR_AND, $constraint, ...$constraints);
}
public static function or(Constraint $constraint, Constraint ...$constraints): CompositeConstraint
{
return new static(self::OPERATOR_OR, $constraint, ...$constraints);
}
public function getOperator(): string
{
return $this->operator;
}
public function getConstraints(): array
{
return $this->constraints;
}
public function assert(Version $version): bool
{
if ($this->operator === self::OPERATOR_AND) {
return $this->assertAnd($version);
}
return $this->assertOr($version);
}
protected function assertAnd(Version $version): bool
{
foreach ($this->constraints as $constraint) {
if (!$constraint->assert($version)) {
return false;
}
}
return true;
}
protected function assertOr(Version $version): bool
{
foreach ($this->constraints as $constraint) {
if ($constraint->assert($version)) {
return true;
}
}
return false;
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Exception/InvalidVersionString.php | src/Exception/InvalidVersionString.php | <?php
declare(strict_types=1);
namespace Version\Exception;
use InvalidArgumentException;
class InvalidVersionString extends InvalidArgumentException implements VersionException
{
protected string $versionString;
public static function notParsable(string $versionString): self
{
$exception = new self(sprintf("Version string '%s' is not valid and cannot be parsed", $versionString));
$exception->versionString = $versionString;
return $exception;
}
public function getVersionString(): string
{
return $this->versionString;
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Exception/InvalidVersion.php | src/Exception/InvalidVersion.php | <?php
declare(strict_types=1);
namespace Version\Exception;
use Assert\InvalidArgumentException;
class InvalidVersion extends InvalidArgumentException implements VersionException
{
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Exception/CollectionIsEmpty.php | src/Exception/CollectionIsEmpty.php | <?php
declare(strict_types=1);
namespace Version\Exception;
use OutOfBoundsException;
final class CollectionIsEmpty extends OutOfBoundsException implements VersionException
{
public static function cannotGetFirst(): self
{
return new self('Cannot get the first Version from an empty collection');
}
public static function cannotGetLast(): self
{
return new self('Cannot get the last Version from an empty collection');
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Exception/VersionException.php | src/Exception/VersionException.php | <?php
declare(strict_types=1);
namespace Version\Exception;
use Throwable;
interface VersionException extends Throwable
{
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Assert/VersionAssert.php | src/Assert/VersionAssert.php | <?php
declare(strict_types=1);
namespace Version\Assert;
use Assert\Assert;
class VersionAssert extends Assert
{
protected static $assertionClass = VersionAssertion::class;
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/src/Assert/VersionAssertion.php | src/Assert/VersionAssertion.php | <?php
declare(strict_types=1);
namespace Version\Assert;
use Assert\Assertion;
use Version\Exception\InvalidVersion;
class VersionAssertion extends Assertion
{
protected static $exceptionClass = InvalidVersion::class;
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/tests/VersionComparisonTest.php | tests/VersionComparisonTest.php | <?php
declare(strict_types=1);
namespace Version\Tests;
use PHPUnit\Framework\TestCase;
use Version\Comparison\Constraint\OperationConstraint;
use Version\Version;
class VersionComparisonTest extends TestCase
{
/**
* @test
*/
public function it_can_be_compared_to_other_version(): void
{
$this->assertSame(1, Version::fromString('2.1.1')->compareTo(Version::fromString('2.1.0')));
}
/**
* @test
*/
public function it_can_be_compared_using_strings(): void
{
$this->assertSame(0, Version::fromString('2.0.0')->compareTo('2.0.0'));
}
/**
* @test
*/
public function it_supports_is_equal_comparison(): void
{
$this->assertTrue(Version::fromString('1.0.0')->isEqualTo('1.0.0'));
}
/**
* @test
*/
public function it_supports_not_equal_comparison(): void
{
$this->assertTrue(Version::fromString('1.0.0')->isNotEqualTo('2.0.0'));
}
/**
* @test
*/
public function it_supports_greater_than_comparison(): void
{
$this->assertTrue(Version::fromString('1.0.1')->isGreaterThan('1.0.0'));
}
/**
* @test
*/
public function it_supports_greater_or_equal_comparison(): void
{
$this->assertTrue(Version::fromString('1.0.0')->isGreaterOrEqualTo('1.0.0'));
}
/**
* @test
*/
public function it_supports_less_than_comparison(): void
{
$this->assertTrue(Version::fromString('1.0.1')->isLessThan('1.0.2'));
}
/**
* @test
*/
public function it_supports_less_or_equal_comparison(): void
{
$this->assertTrue(Version::fromString('1.0.0')->isLessOrEqualTo('1.0.0'));
}
/**
* @test
*/
public function it_supports_matching_comparision_constraint(): void
{
$this->assertTrue(Version::fromString('1.1.0')->matches(OperationConstraint::fromString('>1.0.0')));
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/tests/VersionTest.php | tests/VersionTest.php | <?php
declare(strict_types=1);
namespace Version\Tests;
use PHPUnit\Framework\TestCase;
use Version\Comparison\Comparator;
use Version\Exception\InvalidVersion;
use Version\Exception\InvalidVersionString;
use Version\Extension\Build;
use Version\Extension\PreRelease;
use Version\Tests\TestAsset\VersionIsIdentical;
use Version\Version;
class VersionTest extends TestCase
{
/**
* @test
*/
public function it_is_created_from_version_parts(): void
{
$version = Version::from(
1,
0,
0,
PreRelease::fromString('beta'),
Build::fromString('11')
);
$this->assertThat($version, new VersionIsIdentical(1, 0, 0, 'beta', '11'));
}
/**
* @test
* @dataProvider getVersionStrings
*/
public function it_can_be_created_from_string(string $versionString, int $major, int $minor, int $patch, ?string $preRelease, ?string $build): void
{
$version = Version::fromString($versionString);
$this->assertThat($version, new VersionIsIdentical($major, $minor, $patch, $preRelease, $build));
}
public static function getVersionStrings(): array
{
return [
['0.9.7', 0, 9, 7, null, null],
['1.10.0', 1, 10, 0, null, null],
['2.5.4', 2, 5, 4, null, null],
['2.1.17', 2, 1, 17, null, null],
['3.1.0-beta+123', 3, 1, 0, 'beta', '123'],
['v1.2.3', 1, 2, 3, null, null],
['release-1.2.3', 1, 2, 3, null, null],
];
}
/**
* @test
* @dataProvider getPrintedVersionStrings
*/
public function it_casts_to_string(Version $version, string $versionString): void
{
$this->assertSame($versionString, $version->toString());
}
/**
* @test
* @dataProvider getVersionStrings
*/
public function it_preserves_prefix_when_created_from_string(string $versionString): void
{
$version = Version::fromString($versionString);
$this->assertSame($versionString, $version->toString());
}
public static function getPrefixedVersionStrings(): array
{
return [
['v1.2.3'],
['release-1.2.3'],
];
}
/**
* @test
* @dataProvider getPrintedVersionStrings
*/
public function it_casts_to_json(Version $version, string $versionString): void
{
$this->assertSame('"' . $versionString . '"', json_encode($version));
}
public static function getPrintedVersionStrings(): array
{
return [
[Version::from(2, 1), '2.1.0'],
[Version::fromString('1.0.0+20150919'), '1.0.0+20150919'],
[Version::fromString('1.0.0+exp.sha.5114f85'), '1.0.0+exp.sha.5114f85'],
[Version::fromString('1.0.0-alpha.1+exp.sha.5114f85'), '1.0.0-alpha.1+exp.sha.5114f85'],
];
}
/**
* @test
* @dataProvider getVersionArrays
*/
public function it_casts_to_array(string $versionString, array $versionArray): void
{
$version = Version::fromString($versionString);
$this->assertSame($versionArray, $version->toArray());
}
public static function getVersionArrays(): array
{
return [
[
'1.7.3',
['major' => 1, 'minor' => 7, 'patch' => 3, 'preRelease' => null, 'build' => null]
],
[
'2.0.0-alpha',
['major' => 2, 'minor' => 0, 'patch' => 0, 'preRelease' => ['alpha'], 'build' => null]
],
[
'1.11.3+111',
['major' => 1, 'minor' => 11, 'patch' => 3, 'preRelease' => null, 'build' => ['111']]
],
[
'3.0.0-beta.1+1.2.3',
['major' => 3, 'minor' => 0, 'patch' => 0, 'preRelease' => ['beta', '1'], 'build' => ['1', '2', '3']]
],
];
}
/**
* @test
*/
public function it_is_serializable(): void
{
$version = Version::from(
1,
0,
0,
PreRelease::fromString('beta'),
Build::fromString('123')
);
$serializedVersion = serialize($version);
/** @var Version $deserializedVersion */
$deserializedVersion = unserialize($serializedVersion);
$this->assertTrue($deserializedVersion->isEqualTo($version));
}
/**
* @test
*/
public function it_validates_major_version_number(): void
{
try {
Version::from(-10);
$this->fail('Exception should have been raised');
} catch (InvalidVersion $ex) {
$this->assertSame('Major version must be positive integer', $ex->getMessage());
}
}
/**
* @test
*/
public function it_validates_minor_version_number(): void
{
try {
Version::from(0, -5, 1);
$this->fail('Exception should have been raised');
} catch (InvalidVersion $ex) {
$this->assertSame('Minor version must be positive integer', $ex->getMessage());
}
}
/**
* @test
*/
public function it_validates_patch_version_number(): void
{
try {
Version::from(2, 1, -1);
$this->fail('Exception should have been raised');
} catch (InvalidVersion $ex) {
$this->assertSame('Patch version must be positive integer', $ex->getMessage());
}
}
/**
* @test
* @dataProvider getInvalidVersionStrings
*/
public function it_validates_version_string_input(string $invalidVersion): void
{
try {
Version::fromString($invalidVersion);
$this->fail('Exception should have been raised');
} catch (InvalidVersionString $ex) {
$this->assertSame("Version string '$invalidVersion' is not valid and cannot be parsed", $ex->getMessage());
$this->assertSame($invalidVersion, $ex->getVersionString());
}
}
public static function getInvalidVersionStrings(): array
{
return [
'tooManySubVersions' => ['1.5.2.4.4'],
'leadingZeroIsInvalid' => ['1.05.2'],
];
}
/**
* @test
*/
public function it_allows_setting_custom_comparator_strategy(): void
{
Version::setComparator(new class implements Comparator {
public function compare(Version $version1, Version $version2): int
{
return 1;
}
});
try {
$version = Version::from(1);
$this->assertSame(1, $version->compareTo($version));
} finally {
// reset comparator
Version::setComparator(null);
}
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/tests/VersionExtensionTest.php | tests/VersionExtensionTest.php | <?php
declare(strict_types=1);
namespace Version\Tests;
use PHPUnit\Framework\TestCase;
use Version\Version;
class VersionExtensionTest extends TestCase
{
/**
* @test
*/
public function it_can_include_pre_release_version(): void
{
$version = Version::fromString('1.0.0-alpha');
$this->assertTrue($version->isPreRelease());
$identifiers = $version->getPreRelease()->getIdentifiers();
$this->assertCount(1, $identifiers);
$this->assertSame('alpha', $identifiers[0]);
}
/**
* @test
*/
public function it_can_include_multiple_pre_release_version_identifiers(): void
{
$version = Version::fromString('1.0.0-alpha.1.2');
$identifiers = $version->getPreRelease()->getIdentifiers();
$this->assertCount(3, $identifiers);
$this->assertSame('alpha', $identifiers[0]);
$this->assertSame('1', $identifiers[1]);
$this->assertSame('2', $identifiers[2]);
}
/**
* @test
*/
public function it_can_include_build_metadata(): void
{
$version = Version::fromString('1.0.0+20150919');
$this->assertTrue($version->hasBuild());
$identifiers = $version->getBuild()->getIdentifiers();
$this->assertCount(1, $identifiers);
$this->assertSame('20150919', $identifiers[0]);
}
/**
* @test
*/
public function it_can_include_multiple_build_metadata_identifiers(): void
{
$version = Version::fromString('1.0.0+exp.sha.5114f85');
$identifiers = $version->getBuild()->getIdentifiers();
$this->assertCount(3, $identifiers);
$this->assertSame('exp', $identifiers[0]);
$this->assertSame('sha', $identifiers[1]);
$this->assertSame('5114f85', $identifiers[2]);
}
/**
* @test
*/
public function it_can_include_both_pre_release_and_build_extensions(): void
{
$version = Version::fromString('1.0.0-alpha.1+exp.sha.5114f85');
$preReleaseIdentifiers = $version->getPreRelease()->getIdentifiers();
$this->assertCount(2, $preReleaseIdentifiers);
$this->assertSame('alpha', $preReleaseIdentifiers[0]);
$this->assertSame('1', $preReleaseIdentifiers[1]);
$buildIdentifiers = $version->getBuild()->getIdentifiers();
$this->assertCount(3, $buildIdentifiers);
$this->assertSame('exp', $buildIdentifiers[0]);
$this->assertSame('sha', $buildIdentifiers[1]);
$this->assertSame('5114f85', $buildIdentifiers[2]);
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/tests/VersionOperationsTest.php | tests/VersionOperationsTest.php | <?php
declare(strict_types=1);
namespace Version\Tests;
use PHPUnit\Framework\TestCase;
use Version\Tests\TestAsset\VersionIsIdentical;
use Version\Version;
class VersionOperationsTest extends TestCase
{
/**
* @test
*/
public function it_increments_major_version(): void
{
$version = Version::fromString('1.10.7');
$newVersion = $version->incrementMajor();
$this->assertThat($newVersion, new VersionIsIdentical(2, 0, 0));
}
/**
* @test
*/
public function it_increments_minor_version(): void
{
$version = Version::fromString('2.0.0');
$newVersion = $version->incrementMinor();
$this->assertThat($newVersion, new VersionIsIdentical(2, 1, 0));
}
/**
* @test
*/
public function it_increments_patch_version(): void
{
$version = Version::fromString('2.4.3');
$newVersion = $version->incrementPatch();
$this->assertThat($newVersion, new VersionIsIdentical(2, 4, 4));
}
/**
* @test
*/
public function it_sets_pre_release_version(): void
{
$version = Version::fromString('2.0.0');
$newVersion = $version->withPreRelease('beta');
$this->assertThat($newVersion, new VersionIsIdentical(2, 0, 0, 'beta'));
}
/**
* @test
*/
public function it_sets_build_metadata(): void
{
$version = Version::fromString('2.0.0-beta');
$newVersion = $version->withBuild('111');
$this->assertThat($newVersion, new VersionIsIdentical(2, 0, 0, 'beta', '111'));
}
/**
* @test
*/
public function it_resets_extension_part_when_version_is_incremented(): void
{
$version = Version::fromString('2.0.0-beta+111');
$newVersion = $version->incrementMinor();
$this->assertThat($newVersion, new VersionIsIdentical(2, 1, 0));
}
/**
* @test
*/
public function it_resets_build_metadata_when_setting_pre_release_version(): void
{
$version = Version::fromString('2.0.0+111');
$newVersion = $version->withPreRelease('beta');
$this->assertThat($newVersion, new VersionIsIdentical(2, 0, 0, 'beta'));
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/tests/VersionCollectionTest.php | tests/VersionCollectionTest.php | <?php
declare(strict_types=1);
namespace Version\Tests;
use PHPUnit\Framework\TestCase;
use Version\Exception\CollectionIsEmpty;
use Version\Tests\TestAsset\VersionIsIdentical;
use Version\Tests\TestAsset\VersionCollectionIsIdentical;
use Version\VersionCollection;
use Version\Version;
use Version\Comparison\Constraint\OperationConstraint;
class VersionCollectionTest extends TestCase
{
/**
* @test
*/
public function it_is_created_from_versions_variadic_arguments(): void
{
$versions = new VersionCollection(
Version::fromString('1.0.0'),
Version::fromString('1.1.0'),
Version::fromString('2.3.3')
);
$this->assertThat($versions, new VersionCollectionIsIdentical([
[1, 0, 0, null, null],
[1, 1, 0, null, null],
[2, 3, 3, null, null],
]));
}
/**
* @test
*/
public function it_is_countable(): void
{
$versions = new VersionCollection(
Version::fromString('1.0.0'),
Version::fromString('1.1.0'),
Version::fromString('2.3.3')
);
$this->assertCount(3, $versions);
}
/**
* @test
*/
public function it_checks_for_emptiness(): void
{
$versions = new VersionCollection();
$this->assertTrue($versions->isEmpty());
}
/**
* @test
*/
public function it_gets_first_version(): void
{
$versions = new VersionCollection(
Version::fromString('1.0.0'),
Version::fromString('1.1.0'),
Version::fromString('2.3.3')
);
$version = $versions->first();
$this->assertNotNull($version);
$this->assertThat($version, new VersionIsIdentical(1, 0, 0));
}
/**
* @test
*/
public function it_raises_exception_when_getting_first_item_of_empty_collection(): void
{
$versions = new VersionCollection();
try {
$versions->first();
$this->fail('Exception should have been raised');
} catch (CollectionIsEmpty $ex) {
$this->assertSame('Cannot get the first Version from an empty collection', $ex->getMessage());
}
}
/**
* @test
*/
public function it_gets_last_version(): void
{
$versions = new VersionCollection(
Version::fromString('1.0.0'),
Version::fromString('1.1.0'),
Version::fromString('2.3.3')
);
$version = $versions->last();
$this->assertNotNull($version);
$this->assertThat($version, new VersionIsIdentical(2, 3, 3));
}
/**
* @test
*/
public function it_raises_exception_when_getting_last_item_of_empty_collection(): void
{
$versions = new VersionCollection();
try {
$versions->last();
$this->fail('Exception should have been raised');
} catch (CollectionIsEmpty $ex) {
$this->assertSame('Cannot get the last Version from an empty collection', $ex->getMessage());
}
}
/**
* @test
*/
public function it_is_iterable(): void
{
$versions = new VersionCollection(
Version::fromString('1.0.0'),
Version::fromString('1.1.0'),
Version::fromString('2.3.3')
);
foreach ($versions as $version) {
$this->assertInstanceOf(Version::class, $version);
}
}
/**
* @test
*/
public function it_is_sorted_in_ascending_order(): void
{
$versions = new VersionCollection(
Version::fromString('2.3.3'),
Version::fromString('1.0.0'),
Version::fromString('1.1.0'),
Version::fromString('2.3.3-beta')
);
$versions = $versions->sortedAscending();
$expectedOrder = [
'1.0.0',
'1.1.0',
'2.3.3-beta',
'2.3.3',
];
/** @var Version $version */
foreach ($versions as $key => $version) {
$this->assertSame($expectedOrder[$key], $version->toString());
}
}
/**
* @test
*/
public function it_is_sorted_in_descending_order(): void
{
$versions = new VersionCollection(
Version::fromString('2.3.3'),
Version::fromString('1.0.0'),
Version::fromString('1.1.0')
);
$versions = $versions->sortedDescending();
$expectedOrder = [
'2.3.3',
'1.1.0',
'1.0.0',
];
/** @var Version $version */
foreach ($versions as $key => $version) {
$this->assertSame($expectedOrder[$key], $version->toString());
}
}
/**
* @test
*/
public function it_filters_versions_that_match_constraint(): void
{
$versions = new VersionCollection(
Version::fromString('1.0.0'),
Version::fromString('1.0.1'),
Version::fromString('2.0.0'),
Version::fromString('2.0.1')
);
$versions2 = $versions->matching(OperationConstraint::fromString('>=2.0.0'));
$this->assertThat($versions2, new VersionCollectionIsIdentical([
[2, 0, 0, null, null],
[2, 0, 1, null, null],
]));
}
/**
* @test
*/
public function it_filters_major_releases(): void
{
$releases = new VersionCollection(
Version::fromString('1.0.0'),
Version::fromString('1.1.0'),
Version::fromString('2.0.0'),
Version::fromString('2.1.0'),
Version::fromString('3.0.0'),
Version::fromString('3.0.1')
);
$majorReleases = $releases->majorReleases();
$this->assertThat($majorReleases, new VersionCollectionIsIdentical([
[1, 0, 0, null, null],
[2, 0, 0, null, null],
[3, 0, 0, null, null],
]));
}
/**
* @test
*/
public function it_filters_minor_releases(): void
{
$releases = new VersionCollection(
Version::fromString('1.0.0'),
Version::fromString('1.1.0'),
Version::fromString('2.0.0'),
Version::fromString('2.1.0'),
Version::fromString('2.1.1')
);
$minorReleases = $releases->minorReleases();
$this->assertThat($minorReleases, new VersionCollectionIsIdentical([
[1, 1, 0, null, null],
[2, 1, 0, null, null],
]));
}
/**
* @test
*/
public function it_filters_patch_releases(): void
{
$releases = new VersionCollection(
Version::fromString('1.0.0'),
Version::fromString('1.0.1'),
Version::fromString('2.0.0'),
Version::fromString('2.0.1')
);
$patchReleases = $releases->patchReleases();
$this->assertThat($patchReleases, new VersionCollectionIsIdentical([
[1, 0, 1, null, null],
[2, 0, 1, null, null],
]));
}
/**
* @test
*/
public function it_filters_latest_major_release(): void
{
$releases = new VersionCollection(
Version::fromString('1.0.0'),
Version::fromString('1.1.0'),
Version::fromString('2.0.0'),
Version::fromString('2.1.0'),
Version::fromString('3.0.0'),
Version::fromString('3.0.1')
);
$latestMajorRelease = $releases
->majorReleases()
->sortedDescending()
->first();
$this->assertThat($latestMajorRelease, new VersionIsIdentical(3, 0, 0));
}
/**
* @test
*/
public function it_casts_to_array(): void
{
$versions = new VersionCollection(
Version::fromString('1.0.0'),
Version::fromString('1.0.1'),
Version::fromString('1.1.0')
);
$versionsArray = $versions->toArray();
$this->assertContainsOnlyInstancesOf(Version::class, $versionsArray);
$this->assertCount(3, $versionsArray);
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/tests/Extension/ExtensionTest.php | tests/Extension/ExtensionTest.php | <?php
declare(strict_types=1);
namespace Version\Tests\Extension;
use PHPUnit\Framework\TestCase;
use Version\Exception\InvalidVersion;
use Version\Extension\Extension;
class ExtensionTest extends TestCase
{
/** @var string|Extension */
protected $extensionClassName;
/**
* @test
*/
public function it_is_created_from_identifiers_list(): void
{
$extension = $this->extensionClassName::from('123', '456');
$this->assertSame(['123', '456'], $extension->getIdentifiers());
}
/**
* @test
*/
public function it_can_be_created_from_string(): void
{
$extension = $this->extensionClassName::fromString('123.456');
$this->assertSame(['123', '456'], $extension->getIdentifiers());
}
/**
* @test
*/
public function it_can_be_created_from_array(): void
{
$extension = $this->extensionClassName::fromArray(['123', '456']);
$this->assertSame(['123', '456'], $extension->getIdentifiers());
}
/**
* @test
*/
public function it_casts_to_string(): void
{
$extension = $this->extensionClassName::from('123', '456');
$this->assertSame('123.456', $extension->toString());
}
/**
* @test
*/
public function it_validates_identifier_input(): void
{
try {
$this->extensionClassName::from('$123');
$this->fail('Exception should have been raised');
} catch (InvalidVersion $ex) {
$this->assertStringContainsString('identifiers can include only alphanumerics and hyphen', $ex->getMessage());
}
}
/**
* @test
*/
public function it_validates_empty_identifier_input(): void
{
try {
$this->extensionClassName::from('123', '');
$this->fail('Exception should have been raised');
} catch (InvalidVersion $ex) {
$this->assertStringContainsString('identifiers can include only alphanumerics and hyphen', $ex->getMessage());
}
}
/**
* @test
*/
public function it_validates_empty_array_input(): void
{
try {
$this->extensionClassName::fromArray([]);
$this->fail('Exception should have been raised');
} catch (InvalidVersion $ex) {
$this->assertStringContainsString('must contain at least one identifier', $ex->getMessage());
}
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/tests/Extension/BuildTest.php | tests/Extension/BuildTest.php | <?php
declare(strict_types=1);
namespace Version\Tests\Extension;
use Version\Extension\Build;
class BuildTest extends ExtensionTest
{
protected $extensionClassName = Build::class;
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/tests/Extension/PreReleaseTest.php | tests/Extension/PreReleaseTest.php | <?php
declare(strict_types=1);
namespace Version\Tests\Extension;
use Version\Extension\PreRelease;
class PreReleaseTest extends ExtensionTest
{
protected $extensionClassName = PreRelease::class;
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/tests/Comparison/SemverComparatorTest.php | tests/Comparison/SemverComparatorTest.php | <?php
declare(strict_types=1);
namespace Version\Tests\Comparison;
use PHPUnit\Framework\TestCase;
use Version\Comparison\Comparator;
use Version\Comparison\SemverComparator;
use Version\Version;
class SemverComparatorTest extends TestCase
{
/** @var Comparator */
protected $comparator;
protected function setUp(): void
{
$this->comparator = new SemverComparator();
}
/**
* @test
* @dataProvider getExpectedComparisonResults
*
* @param string $version1String
* @param string $version2String
* @param int $expectedResult
*/
public function it_compares_two_versions(string $version1String, string $version2String, int $expectedResult): void
{
$result = $this->comparator->compare(Version::fromString($version1String), Version::fromString($version2String));
$this->assertSame($expectedResult, $result);
}
public static function getExpectedComparisonResults(): array
{
return [
'major' => ['1.10.1', '2.1.0', -1],
'minor' => ['1.0.0', '1.1.0', -1],
'patch' => ['2.1.1', '2.1.0', 1],
'same' => ['1.0.0', '1.0.0', 0],
'regularVsPreRelease' => ['1.0.0', '1.0.0-alpha', 1],
'preReleaseAlphabeticalComparison' => ['1.0.0-alpha', '1.0.0-beta', -1],
'preReleaseAlphabeticalIdentifiersComparedInOrder' => ['1.0.0-alpha.beta', '1.0.0-beta', -1],
'preReleaseNumericalIdentifiersComparedInOrder' => ['1.0.0-3.alpha', '1.0.0-1.beta', 1],
'longerPreReleaseIsGreaterIfIdentifiersAreTheSame' => ['1.0.0-alpha.1', '1.0.0-alpha', 1],
'multiIdentifierPreReleaseAlphabeticalComparison' => ['1.0.0-alpha.beta', '1.0.0-alpha.1', 1],
'numericPreReleaseIdentifiers' => ['1.0.0-beta.11', '1.0.0-beta.2', 1],
'rcVsBeta' => ['1.0.0-rc.1', '1.0.0-beta.11', 1],
'buildPartIgnored' => ['1.0.0-alpha+20150919', '1.0.0-alpha+exp.sha.5114f85', 0],
'alphanumericPreReleases' => ['1.0.0-b1', '1.0.0-a', 1],
];
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/tests/Comparison/Constraint/CompositeConstraintTest.php | tests/Comparison/Constraint/CompositeConstraintTest.php | <?php
declare(strict_types=1);
namespace Version\Tests\Comparison\Constraint;
use PHPUnit\Framework\TestCase;
use Version\Comparison\Constraint\CompositeConstraint;
use Version\Comparison\Constraint\OperationConstraint;
use Version\Version;
use Version\Comparison\Exception\InvalidCompositeConstraint;
class CompositeConstraintTest extends TestCase
{
/**
* @test
*/
public function it_is_created_from_logical_operator_and_constraints(): void
{
$constraint = new CompositeConstraint(CompositeConstraint::OPERATOR_AND, ...[
new OperationConstraint(OperationConstraint::OPERATOR_GTE, Version::fromString('1.0.0')),
new OperationConstraint(OperationConstraint::OPERATOR_LT, Version::fromString('1.1.0')),
]);
$this->assertInstanceOf(CompositeConstraint::class, $constraint);
$this->assertSame(CompositeConstraint::OPERATOR_AND, $constraint->getOperator());
$this->assertCount(2, $constraint->getConstraints());
}
/**
* @test
*/
public function it_is_created_via_and_named_constructor(): void
{
$constraint = CompositeConstraint::and(...[
new OperationConstraint(OperationConstraint::OPERATOR_GTE, Version::fromString('1.0.0')),
new OperationConstraint(OperationConstraint::OPERATOR_LT, Version::fromString('1.1.0')),
]);
$this->assertSame(CompositeConstraint::OPERATOR_AND, $constraint->getOperator());
}
/**
* @test
*/
public function it_is_created_via_or_named_constructor(): void
{
$constraint = CompositeConstraint::or(...[
new OperationConstraint(OperationConstraint::OPERATOR_GTE, Version::fromString('1.0.0')),
new OperationConstraint(OperationConstraint::OPERATOR_LT, Version::fromString('1.1.0')),
]);
$this->assertSame(CompositeConstraint::OPERATOR_OR, $constraint->getOperator());
}
/**
* @test
*/
public function it_validates_operator_input(): void
{
try {
new CompositeConstraint('invalid', ...[
new OperationConstraint(OperationConstraint::OPERATOR_GTE, Version::fromString('1.0.0')),
]);
$this->fail('Exception should have been raised');
} catch (InvalidCompositeConstraint $ex) {
$this->assertSame('Unsupported composite constraint operator: invalid', $ex->getMessage());
}
}
/**
* @test
*/
public function it_asserts_and_operation_constraint(): void
{
$constraint = CompositeConstraint::and(...[
new OperationConstraint(OperationConstraint::OPERATOR_GTE, Version::fromString('1.0.0')),
new OperationConstraint(OperationConstraint::OPERATOR_LT, Version::fromString('1.1.0')),
]);
$this->assertFalse($constraint->assert(Version::fromString('0.8.7')));
$this->assertTrue($constraint->assert(Version::fromString('1.0.0')));
$this->assertTrue($constraint->assert(Version::fromString('1.0.5')));
$this->assertFalse($constraint->assert(Version::fromString('1.1.0')));
}
/**
* @test
*/
public function it_asserts_or_operation_constraint(): void
{
$constraint = CompositeConstraint::or(...[
new OperationConstraint(OperationConstraint::OPERATOR_EQ, Version::fromString('4.7.1')),
new OperationConstraint(OperationConstraint::OPERATOR_EQ, Version::fromString('5.0.0')),
]);
$this->assertTrue($constraint->assert(Version::fromString('4.7.1')));
$this->assertTrue($constraint->assert(Version::fromString('5.0.0')));
$this->assertFalse($constraint->assert(Version::fromString('1.1.0')));
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/tests/Comparison/Constraint/OperationConstraintTest.php | tests/Comparison/Constraint/OperationConstraintTest.php | <?php
declare(strict_types=1);
namespace Version\Tests\Comparison\Constraint;
use PHPUnit\Framework\TestCase;
use Version\Comparison\Constraint\OperationConstraint;
use Version\Version;
use Version\Comparison\Exception\InvalidOperationConstraint;
class OperationConstraintTest extends TestCase
{
/**
* @test
*/
public function it_is_created_from_operator_and_operand(): void
{
$operand = Version::fromString('1.0.0');
$constraint = new OperationConstraint(OperationConstraint::OPERATOR_GT, $operand);
$this->assertInstanceOf(OperationConstraint::class, $constraint);
$this->assertSame(OperationConstraint::OPERATOR_GT, $constraint->getOperator());
$this->assertSame($operand, $constraint->getOperand());
}
/**
* @test
*/
public function it_is_created_via_named_constructor(): void
{
$operand = Version::fromString('1.2.3');
$constraint = OperationConstraint::equalTo($operand);
$this->assertInstanceOf(OperationConstraint::class, $constraint);
$this->assertSame(OperationConstraint::OPERATOR_EQ, $constraint->getOperator());
$this->assertSame($operand, $constraint->getOperand());
}
/**
* @test
*/
public function it_validates_operator_input(): void
{
try {
new OperationConstraint('invalid', Version::fromString('1.0.0'));
$this->fail('Exception should have been raised');
} catch (InvalidOperationConstraint $ex) {
$this->assertSame('Unsupported constraint operator: invalid', $ex->getMessage());
}
}
/**
* @test
* @dataProvider getConstraintAssertions
*
* @param Version $version
* @param OperationConstraint $constraint
*/
public function it_asserts_provided_version(Version $version, OperationConstraint $constraint): void
{
$this->assertTrue($constraint->assert($version));
}
public static function getConstraintAssertions(): array
{
return [
[
Version::fromString('1.0.0'),
OperationConstraint::equalTo(Version::fromString('1.0.0'))
],
[
Version::fromString('2.0.0'),
OperationConstraint::notEqualTo(Version::fromString('1.0.0'))
],
[
Version::fromString('1.1.0'),
OperationConstraint::greaterThan(Version::fromString('1.0.0'))
],
[
Version::fromString('1.0.0'),
OperationConstraint::greaterOrEqualTo(Version::fromString('1.0.0'))
],
[
Version::fromString('1.0.0'),
OperationConstraint::lessThan(Version::fromString('2.0.0'))
],
[
Version::fromString('1.0.0'),
OperationConstraint::lessOrEqualTo(Version::fromString('1.0.0'))
],
];
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/tests/Comparison/Constraint/OperationConstraintParsingTest.php | tests/Comparison/Constraint/OperationConstraintParsingTest.php | <?php
declare(strict_types=1);
namespace Version\Tests\Comparison\Constraint;
use PHPUnit\Framework\TestCase;
use Version\Comparison\Constraint\OperationConstraint;
use Version\Comparison\Constraint\CompositeConstraint;
use Version\Comparison\Exception\InvalidConstraintString;
class OperationConstraintParsingTest extends TestCase
{
/**
* @test
*/
public function it_parses_simple_constraint(): void
{
$constraint = OperationConstraint::fromString('>=1.2.0');
$this->assertInstanceOf(OperationConstraint::class, $constraint);
$this->assertSame('>=', $constraint->getOperator());
$this->assertSame('1.2.0', $constraint->getOperand()->toString());
}
/**
* @test
*/
public function it_uses_equals_as_default_operator(): void
{
$constraint = OperationConstraint::fromString('1.2.0');
$this->assertInstanceOf(OperationConstraint::class, $constraint);
$this->assertSame('=', $constraint->getOperator());
$this->assertSame('1.2.0', $constraint->getOperand()->toString());
}
/**
* @test
*/
public function it_parses_range_constraint(): void
{
$constraint = OperationConstraint::fromString('>=1.2.3 <1.3.0');
$this->assertInstanceOf(CompositeConstraint::class, $constraint);
$this->assertCompositeConstraintIsIdentical(
$constraint,
CompositeConstraint::OPERATOR_AND,
[
['operator' => '>=', 'operand' => '1.2.3'],
['operator' => '<', 'operand' => '1.3.0'],
]
);
}
/**
* @test
*/
public function it_parses_composite_constraints_that_include_logical_operators(): void
{
$constraint = OperationConstraint::fromString('>=1.0.0 <1.1.0 || >=1.2.0');
$this->assertInstanceOf(CompositeConstraint::class, $constraint);
$this->assertCompositeConstraintIsIdentical(
$constraint,
CompositeConstraint::OPERATOR_OR,
[
[
'operator' => CompositeConstraint::OPERATOR_AND,
'constraints' => [
['operator' => '>=', 'operand' => '1.0.0'],
['operator' => '<', 'operand' => '1.1.0'],
]
],
[
'operator' => CompositeConstraint::OPERATOR_AND,
'constraints' => [
['operator' => '>=', 'operand' => '1.2.0'],
]
],
]
);
}
/**
* @test
*/
public function it_validates_constraint_string_for_emptiness(): void
{
try {
OperationConstraint::fromString(' ');
$this->fail('Exception should have been raised');
} catch (InvalidConstraintString $ex) {
$this->assertSame('Comparison constraint string must not be empty', $ex->getMessage());
}
}
/**
* @test
*/
public function it_validates_constraint_string_operator(): void
{
try {
OperationConstraint::fromString('"100');
$this->fail('Exception should have been raised');
} catch (InvalidConstraintString $ex) {
$this->assertSame("Comparison constraint string: '\"100' is not valid and cannot be parsed", $ex->getMessage());
}
}
/**
* @test
*/
public function it_validates_constraint_string_version_operand(): void
{
try {
OperationConstraint::fromString('>100');
$this->fail('Exception should have been raised');
} catch (InvalidConstraintString $ex) {
$this->assertSame("Comparison constraint string: '>100' is not valid and cannot be parsed", $ex->getMessage());
}
}
/**
* @test
*/
public function it_validates_compound_constraint_string(): void
{
try {
OperationConstraint::fromString('>=1.0.0 <1.1.0 ||');
$this->fail('Exception should have been raised');
} catch (InvalidConstraintString $ex) {
$this->assertSame("Comparison constraint string: '>=1.0.0 <1.1.0 ||' is not valid and cannot be parsed", $ex->getMessage());
}
}
public static function assertCompositeConstraintIsIdentical(CompositeConstraint $compositeConstraint, string $expectedOperator, array $expectedConstraints): void
{
self::assertSame($expectedOperator, $compositeConstraint->getOperator());
foreach ($compositeConstraint->getConstraints() as $i => $constraint) {
/* @var $constraint OperationConstraint */
if ($constraint instanceof CompositeConstraint) {
self::assertCompositeConstraintIsIdentical(
$constraint,
$expectedConstraints[$i]['operator'],
$expectedConstraints[$i]['constraints']
);
continue;
}
self::assertSame($expectedConstraints[$i]['operator'], $constraint->getOperator());
self::assertSame($expectedConstraints[$i]['operand'], $constraint->getOperand()->toString());
}
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/tests/TestAsset/VersionIsIdentical.php | tests/TestAsset/VersionIsIdentical.php | <?php
declare(strict_types=1);
namespace Version\Tests\TestAsset;
use PHPUnit\Framework\Constraint\Constraint;
use Version\Extension\Build;
use Version\Extension\PreRelease;
use Version\Version;
final class VersionIsIdentical extends Constraint
{
private Version $expectedVersion;
public function __construct(
int $expectedMajor,
int $expectedMinor,
int $expectedPatch,
PreRelease|string $expectedPreRelease = null,
Build|string $expectedBuild = null
) {
$this->expectedVersion = Version::from(
$expectedMajor,
$expectedMinor,
$expectedPatch,
is_string($expectedPreRelease) ? PreRelease::fromString($expectedPreRelease) : $expectedPreRelease,
is_string($expectedBuild) ? Build::fromString($expectedBuild) : $expectedBuild
);
}
protected function matches($version): bool
{
/* @var $version Version */
return (
$version->getMajor() === $this->expectedVersion->getMajor()
&& $version->getMinor() === $this->expectedVersion->getMinor()
&& $version->getPatch() === $this->expectedVersion->getPatch()
&& (
($version->isPreRelease() && $this->expectedVersion->isPreRelease() && $version->getPreRelease()->getIdentifiers() === $this->expectedVersion->getPreRelease()->getIdentifiers())
|| (!$version->isPreRelease() && !$this->expectedVersion->isPreRelease())
)
&& (
($version->hasBuild() && $this->expectedVersion->hasBuild() && $version->getBuild()->getIdentifiers() === $this->expectedVersion->getBuild()->getIdentifiers())
|| (!$version->hasBuild() && !$this->expectedVersion->hasBuild())
)
);
}
public function toString(): string
{
return 'is identical to: ' . $this->expectedVersion->toString();
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
nikolaposa/version | https://github.com/nikolaposa/version/blob/d8416651c275f0ac929bb5d86bb8fd92935eb8a7/tests/TestAsset/VersionCollectionIsIdentical.php | tests/TestAsset/VersionCollectionIsIdentical.php | <?php
declare(strict_types=1);
namespace Version\Tests\TestAsset;
use PHPUnit\Framework\Constraint\Constraint;
use Version\Version;
use Version\VersionCollection;
final class VersionCollectionIsIdentical extends Constraint
{
/** @var VersionIsIdentical[] */
private array $isIdenticalConstraints = [];
public function __construct(array $expectedVersions)
{
foreach ($expectedVersions as [$expectedMajor, $expectedMinor, $expectedPatch, $expectedPreRelease, $expectedBuild]) {
$this->isIdenticalConstraints[] = new VersionIsIdentical(
$expectedMajor,
$expectedMinor,
$expectedPatch,
$expectedPreRelease,
$expectedBuild
);
}
}
protected function matches($versions): bool
{
/* @var $versions VersionCollection */
if ($versions->count() !== count($this->isIdenticalConstraints)) {
return false;
}
foreach ($versions->toArray() as $i => $version) {
/* @var $version Version */
if (! isset($this->isIdenticalConstraints[$i])) {
return false;
}
$isIdenticalConstraint = $this->isIdenticalConstraints[$i];
if (!$isIdenticalConstraint->evaluate($version, '', true)) {
return false;
}
}
return true;
}
public function toString(): string
{
return 'content is identical for specified versions';
}
}
| php | MIT | d8416651c275f0ac929bb5d86bb8fd92935eb8a7 | 2026-01-05T04:39:25.959802Z | false |
glamorous/TMDb-PHP-API | https://github.com/glamorous/TMDb-PHP-API/blob/aad8d22fa652a30823c1219d7043bcd96f1e090a/TMDb.php | TMDb.php | <?php
/**
* TMDb PHP API class - API 'themoviedb.org'
* API Documentation: http://help.themoviedb.org/kb/api/
* Documentation and usage in README file
*
* @author Jonas De Smet - Glamorous
* @since 09.11.2009
* @date 16.11.2012
* @copyright Jonas De Smet - Glamorous
* @version 1.5.1
* @license BSD http://www.opensource.org/licenses/bsd-license.php
*/
class TMDb
{
const POST = 'post';
const GET = 'get';
const HEAD = 'head';
const IMAGE_BACKDROP = 'backdrop';
const IMAGE_POSTER = 'poster';
const IMAGE_PROFILE = 'profile';
const API_VERSION = '3';
const API_URL = 'api.themoviedb.org';
const API_SCHEME = 'http://';
const API_SCHEME_SSL = 'https://';
const VERSION = '1.5.0';
/**
* The API-key
*
* @var string
*/
protected $_apikey;
/**
* The default language
*
* @var string
*/
protected $_lang;
/**
* The TMDb-config
*
* @var object
*/
protected $_config;
/**
* Stored Session Id
*
* @var string
*/
protected $_session_id;
/**
* API Scheme
*
* @var string
*/
protected $_apischeme;
/**
* Default constructor
*
* @param string $apikey API-key recieved from TMDb
* @param string $defaultLang Default language (ISO 3166-1)
* @param boolean $config Load the TMDb-config
* @return void
*/
public function __construct($apikey, $default_lang = 'en', $config = FALSE, $scheme = TMDb::API_SCHEME)
{
$this->_apikey = (string) $apikey;
$this->_apischeme = ($scheme == TMDb::API_SCHEME) ? TMDb::API_SCHEME : TMDb::API_SCHEME_SSL;
$this->setLang($default_lang);
if($config === TRUE)
{
$this->getConfiguration();
}
}
/**
* Search a movie by querystring
*
* @param string $text Query to search after in the TMDb database
* @param int $page Number of the page with results (default first page)
* @param bool $adult Whether of not to include adult movies in the results (default FALSE)
* @param mixed $lang Filter the result with a language (ISO 3166-1) other then default, use FALSE to retrieve results from all languages
* @return TMDb result array
*/
public function searchMovie($query, $page = 1, $adult = FALSE, $year = NULL, $lang = NULL)
{
$params = array(
'query' => $query,
'page' => (int) $page,
'language' => ($lang !== NULL) ? $lang : $this->getLang(),
'include_adult' => (bool) $adult,
'year' => $year,
);
return $this->_makeCall('search/movie', $params);
}
/**
* Search a person by querystring
*
* @param string $text Query to search after in the TMDb database
* @param int $page Number of the page with results (default first page)
* @param bool $adult Whether of not to include adult movies in the results (default FALSE)
* @return TMDb result array
*/
public function searchPerson($query, $page = 1, $adult = FALSE)
{
$params = array(
'query' => $query,
'page' => (int) $page,
'include_adult' => (bool) $adult,
);
return $this->_makeCall('search/person', $params);
}
/**
* Search a company by querystring
*
* @param string $text Query to search after in the TMDb database
* @param int $page Number of the page with results (default first page)
* @return TMDb result array
*/
public function searchCompany($query, $page = 1)
{
$params = array(
'query' => $query,
'page' => $page,
);
return $this->_makeCall('search/company', $params);
}
/**
* Retrieve information about a collection
*
* @param int $id Id from a collection (retrieved with getMovie)
* @param mixed $lang Filter the result with a language (ISO 3166-1) other then default, use FALSE to retrieve results from all languages
* @return TMDb result array
*/
public function getCollection($id, $lang = NULL)
{
$params = array(
'language' => ($lang !== NULL) ? $lang : $this->getLang(),
);
return $this->_makeCall('collection/'.$id, $params);
}
/**
* Retrieve all basic information for a particular movie
*
* @param mixed $id TMDb-id or IMDB-id
* @param mixed $lang Filter the result with a language (ISO 3166-1) other then default, use FALSE to retrieve results from all languages
* @return TMDb result array
*/
public function getMovie($id, $lang = NULL)
{
$params = array(
'language' => ($lang !== NULL) ? $lang : $this->getLang(),
);
return $this->_makeCall('movie/'.$id, $params);
}
/**
* Retrieve alternative titles for a particular movie
*
* @param mixed $id TMDb-id or IMDB-id
* @params string $country Only include titles for a particular country (ISO 3166-1)
* @return TMDb result array
*/
public function getMovieTitles($id, $country = NULL)
{
$params = array(
'country' => $country,
);
return $this->_makeCall('movie/'.$id.'/alternative_titles', $params);
}
/**
* Retrieve all of the movie cast information for a particular movie
*
* @param mixed $id TMDb-id or IMDB-id
* @return TMDb result array
*/
public function getMovieCast($id)
{
return $this->_makeCall('movie/'.$id.'/casts');
}
/**
* Retrieve all of the keywords for a particular movie
*
* @param mixed $id TMDb-id or IMDB-id
* @return TMDb result array
*/
public function getMovieKeywords($id)
{
return $this->_makeCall('movie/'.$id.'/keywords');
}
/**
* Retrieve all the release and certification data for a particular movie
*
* @param mixed $id TMDb-id or IMDB-id
* @return TMDb result array
*/
public function getMovieReleases($id)
{
return $this->_makeCall('movie/'.$id.'/releases');
}
/**
* Retrieve available translations for a particular movie
*
* @param mixed $id TMDb-id or IMDB-id
* @return TMDb result array
*/
public function getMovieTranslations($id)
{
return $this->_makeCall('movie/'.$id.'/translations');
}
/**
* Retrieve available trailers for a particular movie
*
* @param mixed $id TMDb-id or IMDB-id
* @param mixed $lang Filter the result with a language (ISO 3166-1) other then default, use FALSE to retrieve results from all languages
* @return TMDb result array
*/
public function getMovieTrailers($id, $lang = NULL)
{
$params = array(
'language' => ($lang !== NULL) ? $lang : $this->getLang(),
);
return $this->_makeCall('movie/'.$id.'/trailers', $params);
}
/**
* Retrieve all images for a particular movie
*
* @param mixed $id TMDb-id or IMDB-id
* @param mixed $lang Filter the result with a language (ISO 3166-1) other then default, use FALSE to retrieve results from all languages
* @return TMDb result array
*/
public function getMovieImages($id, $lang = NULL)
{
$params = array(
'language' => ($lang !== NULL) ? $lang : $this->getLang(),
);
return $this->_makeCall('movie/'.$id.'/images', $params);
}
/**
* Retrieve similar movies for a particular movie
*
* @param mixed $id TMDb-id or IMDB-id
* @param int $page Number of the page with results (default first page)
* @param mixed $lang Filter the result with a language (ISO 3166-1) other then default, use FALSE to retrieve results from all languages
* @return TMDb result array
*/
public function getSimilarMovies($id, $page = 1, $lang = NULL)
{
$params = array(
'page' => (int) $page,
'language' => ($lang !== NULL) ? $lang : $this->getLang(),
);
return $this->_makeCall('movie/'.$id.'/similar_movies', $params);
}
/**
* Retrieve newest movie added to TMDb
*
* @return TMDb result array
*/
public function getLatestMovie()
{
return $this->_makeCall('movie/latest');
}
/**
* Retrieve movies arriving to theatres within the next few weeks
*
* @param int $page Number of the page with results (default first page)
* @param mixed $lang Filter the result with a language (ISO 3166-1) other then default, use FALSE to retrieve results from all languages
* @return TMDb result array
*/
public function getUpcomingMovies($page = 1, $lang = NULL)
{
$params = array(
'page' => (int) $page,
'language' => ($lang !== NULL) ? $lang : $this->getLang(),
);
return $this->_makeCall('movie/upcoming', $params);
}
/**
* Retrieve movies currently in theatres
*
* @param int $page Number of the page with results (default first page)
* @param mixed $lang Filter the result with a language (ISO 3166-1) other then default, use FALSE to retrieve results from all languages
* @return TMDb result array
*/
public function getNowPlayingMovies($page = 1, $lang = NULL)
{
$params = array(
'page' => (int) $page,
'language' => ($lang !== NULL) ? $lang : $this->getLang(),
);
return $this->_makeCall('movie/now_playing', $params);
}
/**
* Retrieve popular movies (list is updated daily)
*
* @param int $page Number of the page with results (default first page)
* @param mixed $lang Filter the result with a language (ISO 3166-1) other then default, use FALSE to retrieve results from all languages
* @return TMDb result array
*/
public function getPopularMovies($page = 1, $lang = NULL)
{
$params = array(
'page' => (int) $page,
'language' => ($lang !== NULL) ? $lang : $this->getLang(),
);
return $this->_makeCall('movie/popular', $params);
}
/**
* Retrieve top-rated movies
*
* @param int $page Number of the page with results (default first page)
* @param mixed $lang Filter the result with a language (ISO 3166-1) other then default, use FALSE to retrieve results from all languages
* @return TMDb result array
*/
public function getTopRatedMovies($page = 1, $lang = NULL)
{
$params = array(
'page' => (int) $page,
'language' => ($lang !== NULL) ? $lang : $this->getLang(),
);
return $this->_makeCall('movie/top_rated', $params);
}
/**
* Retrieve changes for a particular movie
*
* @param mixed $id TMDb-id or IMDB-id
* @return TMDb result array
*/
public function getMovieChanges($id)
{
return $this->_makeCall('movie/'.$id.'/changes');
}
/**
* Retrieve all id's from changed movies
*
* @param int $page Number of the page with results (default first page)
* @param string $start_date String start date as YYYY-MM-DD
* @param string $end_date String end date as YYYY-MM-DD (not inclusive)
* @return TMDb result array
*/
public function getChangedMovies($page = 1, $start_date = NULL, $end_date = NULL)
{
$params = array(
'page' => (int) $page,
'start_date' => $start_date,
'end_date' => $end_date,
);
return $this->_makeCall('movie/changes', $params);
}
/**
* Retrieve all basic information for a particular person
*
* @param int $id TMDb person-id
* @return TMDb result array
*/
public function getPerson($id)
{
return $this->_makeCall('person/'.$id);
}
/**
* Retrieve all cast and crew information for a particular person
*
* @param int $id TMDb person-id
* @param mixed $lang Filter the result with a language (ISO 3166-1) other then default, use FALSE to retrieve results from all languages
* @return TMDb result array
*/
public function getPersonCredits($id, $lang = NULL)
{
$params = array(
'language' => ($lang !== NULL) ? $lang : $this->getLang(),
);
return $this->_makeCall('person/'.$id.'/credits', $params);
}
/**
* Retrieve all images for a particular person
*
* @param mixed $id TMDb person-id
* @return TMDb result array
*/
public function getPersonImages($id)
{
return $this->_makeCall('person/'.$id.'/images');
}
/**
* Retrieve changes for a particular person
*
* @param mixed $id TMDb person-id
* @return TMDb result array
*/
public function getPersonChanges($id)
{
return $this->_makeCall('person/'.$id.'/changes');
}
/**
* Retrieve all id's from changed persons
*
* @param int $page Number of the page with results (default first page)
* @param string $start_date String start date as YYYY-MM-DD
* @param string $end_date String end date as YYYY-MM-DD (not inclusive)
* @return TMDb result array
*/
public function getChangedPersons($page = 1, $start_date = NULL, $end_date = NULL)
{
$params = array(
'page' => (int) $page,
'start_date' => $start_date,
'start_date' => $end_date,
);
return $this->_makeCall('person/changes', $params);
}
/**
* Retrieve all basic information for a particular production company
*
* @param int $id TMDb company-id
* @return TMDb result array
*/
public function getCompany($id)
{
return $this->_makeCall('company/'.$id);
}
/**
* Retrieve movies for a particular production company
*
* @param int $id TMDb company-id
* @param int $page Number of the page with results (default first page)
* @param mixed $lang Filter the result with a language (ISO 3166-1) other then default, use FALSE to retrieve results from all languages
* @return TMDb result array
*/
public function getMoviesByCompany($id, $page = 1, $lang = NULL)
{
$params = array(
'page' => (int) $page,
'language' => ($lang !== NULL) ? $lang : $this->getLang(),
);
return $this->_makeCall('company/'.$id.'/movies', $params);
}
/**
* Retrieve a list of genres used on TMDb
*
* @param mixed $lang Filter the result with a language (ISO 3166-1) other then default, use FALSE to retrieve results from all languages
* @return TMDb result array
*/
public function getGenres($lang = NULL)
{
$params = array(
'language' => ($lang !== NULL) ? $lang : $this->getLang(),
);
return $this->_makeCall('genre/list', $params);
}
/**
* Retrieve movies for a particular genre
*
* @param int $id TMDb genre-id
* @param int $page Number of the page with results (default first page)
* @param mixed $lang Filter the result with a language (ISO 3166-1) other then default, use FALSE to retrieve results from all languages
* @return TMDb result array
*/
public function getMoviesByGenre($id, $page = 1, $lang = NULL)
{
$params = array(
'page' => (int) $page,
'language' => ($lang !== NULL) ? $lang : $this->getLang(),
);
return $this->_makeCall('genre/'.$id.'/movies', $params);
}
/**
* Authentication: retrieve authentication token
* More information about the authentication process: http://help.themoviedb.org/kb/api/user-authentication
*
* @return TMDb result array
*/
public function getAuthToken()
{
$result = $this->_makeCall('authentication/token/new');
if( ! isset($result['request_token']))
{
if($this->getDebugMode())
{
throw new TMDbException('No valid request token from TMDb');
}
else
{
return FALSE;
}
}
return $result;
}
/**
* Authentication: retrieve authentication session and set it to the class
* More information about the authentication process: http://help.themoviedb.org/kb/api/user-authentication
*
* @param string $token
* @return TMDb result array
*/
public function getAuthSession($token)
{
$params = array(
'request_token' => $token,
);
$result = $this->_makeCall('authentication/session/new', $params);
if(isset($result['session_id']))
{
$this->setAuthSession($result['session_id']);
}
return $result;
}
/**
* Authentication: set retrieved session id in the class for authenticated requests
* More information about the authentication process: http://help.themoviedb.org/kb/api/user-authentication
*
* @param string $session_id
*/
public function setAuthSession($session_id)
{
$this->_session_id = $session_id;
}
/**
* Retrieve basic account information
*
* @param string $session_id Set session_id for the account you want to retrieve information from
* @return TMDb result array
*/
public function getAccount($session_id = NULL)
{
$session_id = ($session_id === NULL) ? $this->_session_id : $session_id;
return $this->_makeCall('account', NULL, $session_id);
}
/**
* Retrieve favorite movies for a particular account
*
* @param int $account_id TMDb account-id
* @param string $session_id Set session_id for the account you want to retrieve information from
* @param int $page Number of the page with results (default first page)
* @param mixed $lang Get result in other language then default for this user account (ISO 3166-1)
* @return TMDb result array
*/
public function getAccountFavoriteMovies($account_id, $session_id = NULL, $page = 1, $lang = FALSE)
{
$session_id = ($session_id === NULL) ? $this->_session_id : $session_id;
$params = array(
'page' => (int) $page,
'language' => ($lang !== NULL) ? $lang : '',
);
return $this->_makeCall('account/'.$account_id.'/favorite_movies', $params, $session_id);
}
/**
* Retrieve rated movies for a particular account
*
* @param int $account_id TMDb account-id
* @param string $session_id Set session_id for the account you want to retrieve information from
* @param int $page Number of the page with results (default first page)
* @param mixed $lang Get result in other language then default for this user account (ISO 3166-1)
* @return TMDb result array
*/
public function getAccountRatedMovies($account_id, $session_id = NULL, $page = 1, $lang = FALSE)
{
$session_id = ($session_id === NULL) ? $this->_session_id : $session_id;
$params = array(
'page' => (int) $page,
'language' => ($lang !== NULL) ? $lang : '',
);
return $this->_makeCall('account/'.$account_id.'/rated_movies', $params, $session_id);
}
/**
* Retrieve movies that have been marked in a particular account watchlist
*
* @param int $account_id TMDb account-id
* @param string $session_id Set session_id for the account you want to retrieve information from
* @param int $page Number of the page with results (default first page)
* @param mixed $lang Get result in other language then default for this user account (ISO 3166-1)
* @return TMDb result array
*/
public function getAccountWatchlistMovies($account_id, $session_id = NULL, $page = 1, $lang = FALSE)
{
$session_id = ($session_id === NULL) ? $this->_session_id : $session_id;
$params = array(
'page' => (int) $page,
'language' => ($lang !== NULL) ? $lang : '',
);
return $this->_makeCall('account/'.$account_id.'/movie_watchlist', $params, $session_id);
}
/**
* Add a movie to the account favorite movies
*
* @param int $account_id TMDb account-id
* @param string $session_id Set session_id for the account you want to retrieve information from
* @param int $movie_id TMDb movie-id
* @param bool $favorite Add to favorites or remove from favorites (default TRUE)
* @return TMDb result array
*/
public function addFavoriteMovie($account_id, $session_id = NULL, $movie_id = 0, $favorite = TRUE)
{
$session_id = ($session_id === NULL) ? $this->_session_id : $session_id;
$params = array(
'movie_id' => (int) $movie_id,
'favorite' => (bool) $favorite,
);
return $this->_makeCall('account/'.$account_id.'/favorite', $params, $session_id, TMDb::POST);
}
/**
* Add a movie to the account watchlist
*
* @param int $account_id TMDb account-id
* @param string $session_id Set session_id for the account you want to retrieve information from
* @param int $movie_id TMDb movie-id
* @param bool $watchlist Add to watchlist or remove from watchlist (default TRUE)
* @return TMDb result array
*/
public function addMovieToWatchlist($account_id, $session_id = NULL, $movie_id = 0, $watchlist = TRUE)
{
$session_id = ($session_id === NULL) ? $this->_session_id : $session_id;
$params = array(
'movie_id' => (int) $movie_id,
'movie_watchlist' => (bool) $watchlist,
);
return $this->_makeCall('account/'.$account_id.'/movie_watchlist', $params, $session_id, TMDb::POST);
}
/**
* Add a rating to a movie
*
* @param string $session_id Set session_id for the account you want to retrieve information from
* @param int $movie_id TMDb movie-id
* @param float $value Value between 1 and 10
* @return TMDb result array
*/
public function addMovieRating($session_id = NULL, $movie_id = 0, $value = 0)
{
$session_id = ($session_id === NULL) ? $this->_session_id : $session_id;
$params = array(
'value' => is_numeric($value) ? floatval($value) : 0,
);
return $this->_makeCall('movie/'.$movie_id.'/rating', $params, $session_id, TMDb::POST);
}
/**
* Get configuration from TMDb
*
* @return TMDb result array
*/
public function getConfiguration()
{
$config = $this->_makeCall('configuration');
if( ! empty($config))
{
$this->setConfig($config);
}
return $config;
}
/**
* Get Image URL
*
* @param string $filepath Filepath to image
* @param const $imagetype Image type: TMDb::IMAGE_BACKDROP, TMDb::IMAGE_POSTER, TMDb::IMAGE_PROFILE
* @param string $size Valid size for the image
* @return string
*/
public function getImageUrl($filepath, $imagetype, $size)
{
$config = $this->getConfig();
if(isset($config['images']))
{
$base_url = $config['images']['base_url'];
$available_sizes = $this->getAvailableImageSizes($imagetype);
if(in_array($size, $available_sizes))
{
return $base_url.$size.$filepath;
}
else
{
throw new TMDbException('The size "'.$size.'" is not supported by TMDb');
}
}
else
{
throw new TMDbException('No configuration available for image URL generation');
}
}
/**
* Get available image sizes for a particular image type
*
* @param const $imagetype Image type: TMDb::IMAGE_BACKDROP, TMDb::IMAGE_POSTER, TMDb::IMAGE_PROFILE
* @return array
*/
public function getAvailableImageSizes($imagetype)
{
$config = $this->getConfig();
if(isset($config['images'][$imagetype.'_sizes']))
{
return $config['images'][$imagetype.'_sizes'];
}
else
{
throw new TMDbException('No configuration available to retrieve available image sizes');
}
}
/**
* Get ETag to keep track of state of the content
*
* @param string $uri Use an URI to know the version of it. For example: 'movie/550'
* @return string
*/
public function getVersion($uri)
{
$headers = $this->_makeCall($uri, NULL, NULL, TMDb::HEAD);
return isset($headers['Etag']) ? $headers['Etag'] : '';
}
/**
* Makes the call to the API
*
* @param string $function API specific function name for in the URL
* @param array $params Unencoded parameters for in the URL
* @param string $session_id Session_id for authentication to the API for specific API methods
* @param const $method TMDb::GET or TMDb:POST (default TMDb::GET)
* @return TMDb result array
*/
private function _makeCall($function, $params = NULL, $session_id = NULL, $method = TMDb::GET)
{
$params = ( ! is_array($params)) ? array() : $params;
$auth_array = array('api_key' => $this->_apikey);
if($session_id !== NULL)
{
$auth_array['session_id'] = $session_id;
}
$url = $this->_apischeme.TMDb::API_URL.'/'.TMDb::API_VERSION.'/'.$function.'?'.http_build_query($auth_array, '', '&');
if($method === TMDb::GET)
{
if(isset($params['language']) AND $params['language'] === FALSE)
{
unset($params['language']);
}
$url .= ( ! empty($params)) ? '&'.http_build_query($params, '', '&') : '';
}
$results = '{}';
if (extension_loaded('curl'))
{
$headers = array(
'Accept: application/json',
);
$ch = curl_init();
if($method == TMDB::POST)
{
$json_string = json_encode($params);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $json_string);
$headers[] = 'Content-Type: application/json';
$headers[] = 'Content-Length: '.strlen($json_string);
}
elseif($method == TMDb::HEAD)
{
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD');
curl_setopt($ch, CURLOPT_NOBODY, 1);
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
$error_number = curl_errno($ch);
$error_message = curl_error($ch);
if($error_number > 0)
{
throw new TMDbException('Method failed: '.$function.' - '.$error_message);
}
curl_close($ch);
}
else
{
throw new TMDbException('CURL-extension not loaded');
}
$results = json_decode($body, TRUE);
if(strpos($function, 'authentication/token/new') !== FALSE)
{
$parsed_headers = $this->_http_parse_headers($header);
$results['Authentication-Callback'] = $parsed_headers['Authentication-Callback'];
}
if($results !== NULL)
{
return $results;
}
elseif($method == TMDb::HEAD)
{
return $this->_http_parse_headers($header);
}
else
{
throw new TMDbException('Server error on "'.$url.'": '.$response);
}
}
/**
* Setter for the default language
*
* @param string $lang (ISO 3166-1)
* @return void
*/
public function setLang($lang)
{
$this->_lang = $lang;
}
/**
* Setter for the TMDB-config
*
* $param array $config
* @return void
*/
public function setConfig($config)
{
$this->_config = $config;
}
/**
* Getter for the default language
*
* @return string
*/
public function getLang()
{
return $this->_lang;
}
/**
* Getter for the TMDB-config
*
* @return array
*/
public function getConfig()
{
if(empty($this->_config))
{
$this->_config = $this->getConfiguration();
}
return $this->_config;
}
/*
* Internal function to parse HTTP headers because of lack of PECL extension installed by many
*
* @param string $header
* @return array
*/
protected function _http_parse_headers($header)
{
$return = array();
$fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $header));
foreach($fields as $field)
{
if(preg_match('/([^:]+): (.+)/m', $field, $match))
{
$match[1] = preg_replace('/(?<=^|[\x09\x20\x2D])./e', 'strtoupper("\0")', strtolower(trim($match[1])));
if( isset($return[$match[1]]) )
{
$return[$match[1]] = array($return[$match[1]], $match[2]);
}
else
{
$return[$match[1]] = trim($match[2]);
}
}
}
return $return;
}
}
/**
* TMDb Exception class
*
* @author Jonas De Smet - Glamorous
*/
class TMDbException extends Exception{}
?>
| php | BSD-3-Clause | aad8d22fa652a30823c1219d7043bcd96f1e090a | 2026-01-05T04:39:35.430293Z | false |
rdohms/phpunit-arraysubset-asserts | https://github.com/rdohms/phpunit-arraysubset-asserts/blob/1aa0d838475b1b3de642aa7ad022fadc1e0f5a75/assertarraysubset-autoload.php | assertarraysubset-autoload.php | <?php
namespace DMS\PHPUnitExtensions\ArraySubset;
use PHPUnit\Runner\Version as PHPUnit_Version;
use PHPUnit_Runner_Version;
if (\class_exists('DMS\PHPUnitExtensions\ArraySubset\Autoload', false) === false) {
/**
* Custom autoloader.
*
* {@internal The code in this file must be PHP cross-version compatible for PHP 5.4 - current!}
*/
class Autoload
{
/**
* Loads a class.
*
* @param string $className The name of the class to load.
*
* @return bool
*/
public static function load($className)
{
// Only load classes belonging to this library.
if (\stripos($className, 'DMS\PHPUnitExtensions\ArraySubset') !== 0) {
return false;
}
$loadPolyfill = \version_compare(self::getPHPUnitVersion(), '8.0.0', '>=');
switch ($className) {
case 'DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts':
if ($loadPolyfill === true) {
// PHPUnit >= 8.0.0.
require_once __DIR__ . '/src/ArraySubsetAsserts.php';
return true;
}
// PHPUnit < 8.0.0.
require_once __DIR__ . '/src/ArraySubsetAssertsEmpty.php';
return true;
case 'DMS\PHPUnitExtensions\ArraySubset\Assert':
if ($loadPolyfill === true) {
// PHPUnit >= 8.0.0.
require_once __DIR__ . '/src/Assert.php';
return true;
}
// PHPUnit < 8.0.0.
require_once __DIR__ . '/src/AssertFallThrough.php';
return true;
/*
* Handle arbitrary additional classes via PSR-4, but only allow loading on PHPUnit >= 8.0.0,
* as additional classes should only ever _need_ to be loaded when using PHPUnit >= 8.0.0.
*/
default:
if ($loadPolyfill === false) {
// PHPUnit < 9.0.0.
throw new \RuntimeException(
\sprintf(
'Using class "%s" is only supported in combination with PHPUnit >= 8.0.0',
$className
)
);
}
// PHPUnit >= 8.0.0.
$file = \realpath(
__DIR__ . \DIRECTORY_SEPARATOR
. 'src' . \DIRECTORY_SEPARATOR
. \strtr(\substr($className, 33), '\\', \DIRECTORY_SEPARATOR) . '.php'
);
if (\file_exists($file) === true) {
require_once $file;
return true;
}
}
return false;
}
/**
* Retrieve the PHPUnit version id.
*
* As both the pre-PHPUnit 6 class, as well as the PHPUnit 6+ class contain the `id()` function,
* this should work independently of whether or not another library may have aliased the class.
*
* @return string Version number as a string.
*/
public static function getPHPUnitVersion()
{
if (\class_exists('\PHPUnit\Runner\Version')) {
return PHPUnit_Version::id();
}
if (\class_exists('\PHPUnit_Runner_Version')) {
return PHPUnit_Runner_Version::id();
}
return '0';
}
}
\spl_autoload_register(__NAMESPACE__ . '\Autoload::load');
}
| php | MIT | 1aa0d838475b1b3de642aa7ad022fadc1e0f5a75 | 2026-01-05T04:39:41.859607Z | false |
rdohms/phpunit-arraysubset-asserts | https://github.com/rdohms/phpunit-arraysubset-asserts/blob/1aa0d838475b1b3de642aa7ad022fadc1e0f5a75/src/AssertFallThrough.php | src/AssertFallThrough.php | <?php
namespace DMS\PHPUnitExtensions\ArraySubset;
use PHPUnit\Framework\Assert as PhpUnitAssert;
/**
* Assert class for use with PHPUnit 4.x - 7.x.
*
* The method in this class will fall through to PHPUnit itself and use the PHPUnit
* native `assertArraySubset()` method.
*
* {@internal The code in this file must be PHP cross-version compatible for PHP 5.4 - current!}
*/
final class Assert
{
/**
* Asserts that an array has a specified subset.
*
* @param array|ArrayAccess|mixed[] $subset
* @param array|ArrayAccess|mixed[] $array
* @param bool $checkForObjectIdentity
* @param string $message
*
* @throws ExpectationFailedException
* @throws InvalidArgumentException|Exception
* @throws Exception
*/
public static function assertArraySubset($subset, $array, $checkForObjectIdentity = false, $message = '')
{
PhpUnitAssert::assertArraySubset($subset, $array, $checkForObjectIdentity, $message);
}
}
| php | MIT | 1aa0d838475b1b3de642aa7ad022fadc1e0f5a75 | 2026-01-05T04:39:41.859607Z | false |
rdohms/phpunit-arraysubset-asserts | https://github.com/rdohms/phpunit-arraysubset-asserts/blob/1aa0d838475b1b3de642aa7ad022fadc1e0f5a75/src/ArrayAccessible.php | src/ArrayAccessible.php | <?php
declare(strict_types=1);
namespace DMS\PHPUnitExtensions\ArraySubset;
use ArrayAccess;
use ArrayIterator;
use IteratorAggregate;
use ReturnTypeWillChange;
use Traversable;
use function array_key_exists;
class ArrayAccessible implements ArrayAccess, IteratorAggregate
{
/**
* @var mixed[]
*/
private $array;
/**
* @param mixed[] $array
*/
public function __construct(array $array = [])
{
$this->array = $array;
}
/**
* @param mixed $offset
*/
public function offsetExists($offset): bool
{
return array_key_exists($offset, $this->array);
}
/**
* @param mixed $offset
*
* @return mixed
*/
#[ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->array[$offset];
}
/**
* @param mixed $offset
* @param mixed $value
*/
public function offsetSet($offset, $value): void
{
if ($offset === null) {
$this->array[] = $value;
} else {
$this->array[$offset] = $value;
}
}
/**
* @param mixed $offset
*/
public function offsetUnset($offset): void
{
unset($this->array[$offset]);
}
/**
* @return mixed[]
*/
public function getIterator(): Traversable
{
return new ArrayIterator($this->array);
}
}
| php | MIT | 1aa0d838475b1b3de642aa7ad022fadc1e0f5a75 | 2026-01-05T04:39:41.859607Z | false |
rdohms/phpunit-arraysubset-asserts | https://github.com/rdohms/phpunit-arraysubset-asserts/blob/1aa0d838475b1b3de642aa7ad022fadc1e0f5a75/src/ArraySubsetAsserts.php | src/ArraySubsetAsserts.php | <?php
declare(strict_types=1);
namespace DMS\PHPUnitExtensions\ArraySubset;
use ArrayAccess;
use DMS\PHPUnitExtensions\ArraySubset\Constraint\ArraySubset;
use Exception;
use InvalidArgumentException;
use PHPUnit\Framework\Assert as PhpUnitAssert;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\InvalidArgumentException as PHPUnitInvalidArgumentException;
use PHPUnit\Util\InvalidArgumentHelper;
use function class_exists;
use function is_array;
use function method_exists;
trait ArraySubsetAsserts
{
/**
* Asserts that an array has a specified subset.
*
* @param array|ArrayAccess|mixed[] $subset
* @param array|ArrayAccess|mixed[] $array
*
* @throws ExpectationFailedException
* @throws InvalidArgumentException
* @throws Exception
*/
public static function assertArraySubset($subset, $array, bool $checkForObjectIdentity = false, string $message = ''): void
{
if (! (is_array($subset) || $subset instanceof ArrayAccess)) {
if (
class_exists(PHPUnitInvalidArgumentException::class)
&& method_exists(PHPUnitInvalidArgumentException::class, 'create')
) {
// PHPUnit 8.4.0+ < 10.0.0.
throw PHPUnitInvalidArgumentException::create(
1,
'array or ArrayAccess'
);
}
// PHPUnit < 8.4.0.
if (class_exists(InvalidArgumentHelper::class)) {
throw InvalidArgumentHelper::factory(
1,
'array or ArrayAccess'
);
}
// PHPUnit 10+
throw new InvalidArgumentException('Argument #1 $subset of assertArraySubset() must be array or ArrayAccess.');
}
if (! (is_array($array) || $array instanceof ArrayAccess)) {
if (
class_exists(PHPUnitInvalidArgumentException::class)
&& method_exists(PHPUnitInvalidArgumentException::class, 'create')
) {
// PHPUnit 8.4.0+ < 10.0.0.
throw PHPUnitInvalidArgumentException::create(
2,
'array or ArrayAccess'
);
}
// PHPUnit < 8.4.0.
if (class_exists(InvalidArgumentHelper::class)) {
throw InvalidArgumentHelper::factory(
2,
'array or ArrayAccess'
);
}
// PHPUnit 10+
throw new InvalidArgumentException('Argument #2 array of assertArraySubset() must be array or ArrayAccess.');
}
$constraint = new ArraySubset($subset, $checkForObjectIdentity);
PhpUnitAssert::assertThat($array, $constraint, $message);
}
}
| php | MIT | 1aa0d838475b1b3de642aa7ad022fadc1e0f5a75 | 2026-01-05T04:39:41.859607Z | false |
rdohms/phpunit-arraysubset-asserts | https://github.com/rdohms/phpunit-arraysubset-asserts/blob/1aa0d838475b1b3de642aa7ad022fadc1e0f5a75/src/ArraySubsetAssertsEmpty.php | src/ArraySubsetAssertsEmpty.php | <?php
namespace DMS\PHPUnitExtensions\ArraySubset;
/**
* ArraySubsetAsserts trait for use with PHPUnit 4.x - 7.x.
*
* As this trait is empty, calls to `assertArraySubset()` will automatically fall through
* to PHPUnit itself and will use the PHPUnit native `assertArraySubset()` method.
*
* {@internal The code in this file must be PHP cross-version compatible for PHP 5.4 - current!}
*/
trait ArraySubsetAsserts
{
}
| php | MIT | 1aa0d838475b1b3de642aa7ad022fadc1e0f5a75 | 2026-01-05T04:39:41.859607Z | false |
rdohms/phpunit-arraysubset-asserts | https://github.com/rdohms/phpunit-arraysubset-asserts/blob/1aa0d838475b1b3de642aa7ad022fadc1e0f5a75/src/Assert.php | src/Assert.php | <?php
declare(strict_types=1);
namespace DMS\PHPUnitExtensions\ArraySubset;
final class Assert
{
use ArraySubsetAsserts;
}
| php | MIT | 1aa0d838475b1b3de642aa7ad022fadc1e0f5a75 | 2026-01-05T04:39:41.859607Z | false |
rdohms/phpunit-arraysubset-asserts | https://github.com/rdohms/phpunit-arraysubset-asserts/blob/1aa0d838475b1b3de642aa7ad022fadc1e0f5a75/src/Constraint/ArraySubset.php | src/Constraint/ArraySubset.php | <?php
declare(strict_types=1);
namespace DMS\PHPUnitExtensions\ArraySubset\Constraint;
use ArrayAccess;
use ArrayObject;
use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\SebastianBergmann\Comparator\ComparisonFailure as Phar_ComparisonFailure;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\RecursionContext\InvalidArgumentException;
use Traversable;
use function array_replace_recursive;
use function class_exists;
use function is_array;
use function iterator_to_array;
use function var_export;
/**
* Constraint that asserts that the array it is evaluated for has a specified subset.
*
* Uses array_replace_recursive() to check if a key value subset is part of the
* subject array.
*/
final class ArraySubset extends Constraint
{
/**
* @var iterable|mixed[]
*/
private $subset;
/**
* @var bool
*/
private $strict;
/**
* @param mixed[] $subset
*/
public function __construct(iterable $subset, bool $strict = false)
{
$this->strict = $strict;
$this->subset = $subset;
}
/**
* Evaluates the constraint for parameter $other
*
* If $returnResult is set to false (the default), an exception is thrown
* in case of a failure. null is returned otherwise.
*
* If $returnResult is true, the result of the evaluation is returned as
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @param mixed[]|ArrayAccess $other
*
* @return mixed[]|bool|null
*
* @throws ExpectationFailedException
* @throws InvalidArgumentException|Exception
*/
public function evaluate($other, string $description = '', bool $returnResult = false): ?bool
{
//type cast $other & $this->subset as an array to allow
//support in standard array functions.
$other = $this->toArray($other);
$this->subset = $this->toArray($this->subset);
$patched = array_replace_recursive($other, $this->subset);
if ($this->strict) {
$result = $other === $patched;
} else {
$result = $other == $patched;
}
if ($returnResult) {
return $result;
}
if ($result) {
return null;
}
// Support use of this library when running PHPUnit as a Phar.
if (class_exists(Phar_ComparisonFailure::class) === true) {
$class = Phar_ComparisonFailure::class;
} else {
$class = ComparisonFailure::class;
}
$f = new $class(
$patched,
$other,
var_export($patched, true),
var_export($other, true)
);
$this->fail($other, $description, $f);
}
/**
* Returns a string representation of the constraint.
*
* @throws InvalidArgumentException|Exception
*/
public function toString(): string
{
return 'has the subset ' . $this->exporter()->export($this->subset);
}
/**
* Returns the description of the failure
*
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other evaluated value or object
*
* @throws InvalidArgumentException|Exception
*/
protected function failureDescription($other): string
{
return 'an array ' . $this->toString();
}
/**
* @param mixed[]|iterable $other
*
* @return mixed[]
*/
private function toArray(iterable $other): array
{
if (is_array($other)) {
return $other;
}
if ($other instanceof ArrayObject) {
return $other->getArrayCopy();
}
if ($other instanceof Traversable) {
return iterator_to_array($other);
}
// Keep BC even if we know that array would not be the expected one
return (array) $other;
}
}
| php | MIT | 1aa0d838475b1b3de642aa7ad022fadc1e0f5a75 | 2026-01-05T04:39:41.859607Z | false |
rdohms/phpunit-arraysubset-asserts | https://github.com/rdohms/phpunit-arraysubset-asserts/blob/1aa0d838475b1b3de642aa7ad022fadc1e0f5a75/tests/bootstrap.php | tests/bootstrap.php | <?php
/**
* PHPUnit bootstrap file.
*
* {@internal The code in this file must be PHP cross-version compatible for PHP 5.4 - current!}
*/
if (defined('__PHPUNIT_PHAR__')) {
// Testing via a PHPUnit phar.
require_once __DIR__ . '/../assertarraysubset-autoload.php';
} elseif (file_exists(__DIR__ . '/../vendor/autoload.php')) {
// Testing via a Composer install.
require_once __DIR__ . '/../vendor/autoload.php';
} else {
echo 'Run "composer install" before attempting to run the tests.';
exit(1);
}
| php | MIT | 1aa0d838475b1b3de642aa7ad022fadc1e0f5a75 | 2026-01-05T04:39:41.859607Z | false |
rdohms/phpunit-arraysubset-asserts | https://github.com/rdohms/phpunit-arraysubset-asserts/blob/1aa0d838475b1b3de642aa7ad022fadc1e0f5a75/tests/Unit/AssertTest.php | tests/Unit/AssertTest.php | <?php
declare(strict_types=1);
namespace DMS\PHPUnitExtensions\ArraySubset\Tests\Unit;
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use InvalidArgumentException;
use PHPUnit\Framework\Exception as PHPUnitException;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\InvalidArgumentException as PHPUnitInvalidArgumentException;
use PHPUnit\Framework\TestCase;
use PHPUnit\Util\InvalidArgumentHelper;
use function class_exists;
use function method_exists;
/**
* @requires PHPUnit >= 8
*/
final class AssertTest extends TestCase
{
public function testAssertArraySubsetPassesStrictConfig(): void
{
$this->expectException(ExpectationFailedException::class);
Assert::assertArraySubset(['bar' => 0], ['bar' => '0'], true);
}
public function testAssertArraySubsetThrowsExceptionForInvalidSubset(): void
{
$this->expectException(ExpectationFailedException::class);
Assert::assertArraySubset([6, 7], [1, 2, 3, 4, 5, 6]);
}
public function testAssertArraySubsetThrowsExceptionForInvalidSubsetArgument(): void
{
$this->expectException($this->getExpectedExceptionByVersion());
Assert::assertArraySubset('string', '');
}
public function testAssertArraySubsetThrowsExceptionForInvalidArrayArgument(): void
{
$this->expectException($this->getExpectedExceptionByVersion());
Assert::assertArraySubset([], '');
}
public function testAssertArraySubsetDoesNothingForValidScenario(): void
{
Assert::assertArraySubset([1, 2], [1, 2, 3]);
}
private function getExpectedExceptionByVersion(): string
{
if (
class_exists(PHPUnitInvalidArgumentException::class)
&& method_exists(PHPUnitInvalidArgumentException::class, 'create')
) {
return PHPUnitException::class;
}
if (class_exists(InvalidArgumentHelper::class)) {
return PHPUnitException::class;
}
return InvalidArgumentException::class;
}
}
| php | MIT | 1aa0d838475b1b3de642aa7ad022fadc1e0f5a75 | 2026-01-05T04:39:41.859607Z | false |
rdohms/phpunit-arraysubset-asserts | https://github.com/rdohms/phpunit-arraysubset-asserts/blob/1aa0d838475b1b3de642aa7ad022fadc1e0f5a75/tests/Unit/Constraint/ArraySubsetTest.php | tests/Unit/Constraint/ArraySubsetTest.php | <?php
declare(strict_types=1);
namespace DMS\PHPUnitExtensions\ArraySubset\Tests\Unit\Constraint;
use ArrayObject;
use Countable;
use DMS\PHPUnitExtensions\ArraySubset\ArrayAccessible;
use DMS\PHPUnitExtensions\ArraySubset\Constraint\ArraySubset;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\SelfDescribing;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use SebastianBergmann\RecursionContext\InvalidArgumentException;
use Traversable;
use function sprintf;
/**
* @requires PHPUnit >= 8
*/
final class ArraySubsetTest extends TestCase
{
/**
* @return mixed[]
*/
public static function evaluateDataProvider(): array
{
return [
'loose array subset and array other' => [
'expected' => true,
'subset' => ['bar' => 0],
'other' => ['foo' => '', 'bar' => '0'],
'strict' => false,
],
'strict array subset and array other' => [
'expected' => false,
'subset' => ['bar' => 0],
'other' => ['foo' => '', 'bar' => '0'],
'strict' => true,
],
'loose array subset and ArrayObject other' => [
'expected' => true,
'subset' => ['bar' => 0],
'other' => new ArrayObject(['foo' => '', 'bar' => '0']),
'strict' => false,
],
'strict ArrayObject subset and array other' => [
'expected' => true,
'subset' => new ArrayObject(['bar' => 0]),
'other' => ['foo' => '', 'bar' => 0],
'strict' => true,
],
];
}
/**
* @param array|Traversable|mixed[] $subset
* @param array|Traversable|mixed[] $other
*
* @throws ExpectationFailedException
* @throws InvalidArgumentException|Exception
*
* @dataProvider evaluateDataProvider
*/
public function testEvaluate(bool $expected, $subset, $other, bool $strict): void
{
$constraint = new ArraySubset($subset, $strict);
$this->assertSame($expected, $constraint->evaluate($other, '', true));
}
public function testEvaluateWithArrayAccess(): void
{
$arrayAccess = new ArrayAccessible(['foo' => 'bar']);
$constraint = new ArraySubset(['foo' => 'bar']);
$this->assertTrue($constraint->evaluate($arrayAccess, '', true));
}
public function testEvaluateFailMessage(): void
{
$constraint = new ArraySubset(['foo' => 'bar']);
try {
$constraint->evaluate(['baz' => 'bar'], '', false);
$this->fail(sprintf('Expected %s to be thrown.', ExpectationFailedException::class));
} catch (ExpectationFailedException $expectedException) {
$comparisonFailure = $expectedException->getComparisonFailure();
$this->assertNotNull($comparisonFailure);
$this->assertStringContainsString("'foo' => 'bar'", $comparisonFailure->getExpectedAsString());
$this->assertStringContainsString("'baz' => 'bar'", $comparisonFailure->getActualAsString());
}
}
public function testIsCountable(): void
{
$reflection = new ReflectionClass(ArraySubset::class);
$this->assertTrue(
$reflection->implementsInterface(Countable::class),
sprintf(
'Failed to assert that ArraySubset implements "%s".',
Countable::class
)
);
}
public function testIsSelfDescribing(): void
{
$reflection = new ReflectionClass(ArraySubset::class);
$this->assertTrue(
$reflection->implementsInterface(SelfDescribing::class),
sprintf(
'Failed to assert that Array implements "%s".',
SelfDescribing::class
)
);
}
}
| php | MIT | 1aa0d838475b1b3de642aa7ad022fadc1e0f5a75 | 2026-01-05T04:39:41.859607Z | false |
rdohms/phpunit-arraysubset-asserts | https://github.com/rdohms/phpunit-arraysubset-asserts/blob/1aa0d838475b1b3de642aa7ad022fadc1e0f5a75/tests/Availability/AvailibilityViaClassTest.php | tests/Availability/AvailibilityViaClassTest.php | <?php
namespace DMS\PHPUnitExtensions\ArraySubset\Tests\Availibility;
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PHPUnit\Framework\TestCase;
/**
* Testing that the autoloading of the fall-through `Assert` class for PHPUnit 4.x - 7.x works correctly.
*
* {@internal The code in this file must be PHP cross-version compatible for PHP 5.4 - current!}
*/
final class AvailibilityViaClassTest extends TestCase
{
public function testAssertArraySubsetisAvailabe()
{
Assert::assertArraySubset([1, 2], [1, 2, 3]);
}
}
| php | MIT | 1aa0d838475b1b3de642aa7ad022fadc1e0f5a75 | 2026-01-05T04:39:41.859607Z | false |
rdohms/phpunit-arraysubset-asserts | https://github.com/rdohms/phpunit-arraysubset-asserts/blob/1aa0d838475b1b3de642aa7ad022fadc1e0f5a75/tests/Availability/AutoloadExceptionTest.php | tests/Availability/AutoloadExceptionTest.php | <?php
namespace DMS\PHPUnitExtensions\ArraySubset\Tests\Availibility;
use DMS\PHPUnitExtensions\ArraySubset\Constraint\ArraySubset;
use PHPUnit\Framework\TestCase;
/**
* Testing that autoloading classes which should only ever be loaded on PHPUnit >= 8 will
* generate an exception when attempted on PHPUnit < 8.
*
* Note: the autoloading in combination with PHPUnit 8+ is automatically tested via the
* actual tests for the polyfill as the class will be called upon.
*
* {@internal The code in this file must be PHP cross-version compatible for PHP 5.4 - current!}
*
* @requires PHPUnit < 8
*/
final class AutoloadExceptionTest extends TestCase
{
public function testAutoloadException()
{
$expection = '\RuntimeException';
$message = 'Using class "DMS\PHPUnitExtensions\ArraySubset\Constraint\ArraySubset" is only supported in combination with PHPUnit >= 8.0.0';
if (\method_exists('\PHPUnit\Framework\TestCase', 'expectException') === true) {
$this->expectException($expection);
$this->expectExceptionMessage($message);
} else {
$this->setExpectedException($expection, $message);
}
new ArraySubset();
}
}
| php | MIT | 1aa0d838475b1b3de642aa7ad022fadc1e0f5a75 | 2026-01-05T04:39:41.859607Z | false |
rdohms/phpunit-arraysubset-asserts | https://github.com/rdohms/phpunit-arraysubset-asserts/blob/1aa0d838475b1b3de642aa7ad022fadc1e0f5a75/tests/Availability/AvailibilityViaTraitTest.php | tests/Availability/AvailibilityViaTraitTest.php | <?php
namespace DMS\PHPUnitExtensions\ArraySubset\Tests\Availibility;
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
use PHPUnit\Framework\TestCase;
/**
* Testing that the autoloading of the empty `ArraySubsetAsserts` trait for PHPUnit 4.x - 7.x works correctly.
*
* {@internal The code in this file must be PHP cross-version compatible for PHP 5.4 - current!}
*/
final class AvailibilityViaTraitTest extends TestCase
{
use ArraySubsetAsserts;
public function testAssertArraySubsetisAvailabe()
{
static::assertArraySubset([1, 2], [1, 2, 3]);
$this->assertArraySubset([1, 2], [1, 2, 3]);
}
}
| php | MIT | 1aa0d838475b1b3de642aa7ad022fadc1e0f5a75 | 2026-01-05T04:39:41.859607Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/server.php | server.php | <?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylorotwell@gmail.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri))
{
return false;
}
require_once __DIR__.'/public/index.php';
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/User.php | app/User.php | <?php namespace App;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
use Authenticatable, CanResetPassword;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name', 'email', 'password'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['password', 'remember_token'];
/**
* A user has many podcasts
*/
public function podcasts()
{
return $this->hasMany('App\Podcast');
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Podcast.php | app/Podcast.php | <?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Podcast extends Model {
protected $fillable = ['name', 'user_id', 'machine_name', 'web_url', 'feed_url', 'feed_thumbnail_location'];
/**
* A podcast has many items
*/
public function items()
{
return $this->hasMany('App\Item');
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Item.php | app/Item.php | <?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Item extends Model {
protected $fillable = ['user_id', 'podcast_id', 'title', 'description', 'url', 'audio_url','published_at'];
/**
* An item belongs to a podcast
*/
public function podcast()
{
return $this->belongsTo('App\Podcast');
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Exceptions/Handler.php | app/Exceptions/Handler.php | <?php namespace App\Exceptions;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler {
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
'Symfony\Component\HttpKernel\Exception\HttpException'
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
return parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
return parent::render($request, $e);
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Http/routes.php | app/Http/routes.php | <?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', 'PodcastController@index');
Route::get('podcast/player', 'PodcastController@index');
Route::get('podcast/manage', 'PodcastController@manage');
Route::get('podcast/favorites', 'PodcastController@favorites');
Route::get('podcast/settings', 'PodcastController@settings');
Route::post('podcast/add', 'PodcastController@add');
Route::post('podcast/delete', 'PodcastController@delete');
Route::get('podcast/auto-update', function () {
$exitCode = \Artisan::call('updatePodcastItems');
if ($exitCode == 0) {
return redirect('podcast/player');
}
});
Route::get('item/search', 'ItemController@search');
Route::post('item/mark-as-read', 'ItemController@markAsRead');
Route::post('item/mark-as-favorite', 'ItemController@markAsFavorite');
Route::post('item/mark-all-prev-read', 'ItemController@markAllPrevAsRead');
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Http/Kernel.php | app/Http/Kernel.php | <?php namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel {
/**
* The application's global HTTP middleware stack.
*
* @var array
*/
protected $middleware = [
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
'Illuminate\Cookie\Middleware\EncryptCookies',
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
'Illuminate\Session\Middleware\StartSession',
'Illuminate\View\Middleware\ShareErrorsFromSession',
'App\Http\Middleware\VerifyCsrfToken',
];
/**
* The application's route middleware.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => 'App\Http\Middleware\Authenticate',
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
];
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Http/Requests/Request.php | app/Http/Requests/Request.php | <?php namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
abstract class Request extends FormRequest {
//
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Http/Controllers/Controller.php | app/Http/Controllers/Controller.php | <?php namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
abstract class Controller extends BaseController {
use DispatchesCommands, ValidatesRequests;
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Http/Controllers/ItemController.php | app/Http/Controllers/ItemController.php | <?php namespace App\Http\Controllers;
use App\Item;
use Auth;
use DB;
use Request;
class ItemController extends Controller {
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct() {
$this->middleware('auth');
}
/**
* [markAsRead mark a podcast item as read]
* @return array
*/
public function markAsRead() {
$result['status'] = 0;
$result['message'] = 'Something went wrong, please try again';
$itemId = trim(strip_tags(Request::get('itemId')));
$item = DB::table('items')->select('user_id')
->where('user_id', '=', Auth::user()->id)
->where('id', '=', $itemId)
->first();
// if item with id exists in DB and is owned by the authenticated user
if ($item) {
$podcastItem = Item::findOrFail($itemId);
$podcastItem->is_mark_as_read = 1;
$podcastItem->save();
$result['status'] = 1;
$result['message'] = 'This item has been marked as read';
}
return $result;
}
/**
* [markAllPrevAsRead mark all previous item in a podcast as read]
* @return array
*/
public function markAllPrevAsRead() {
$result['status'] = 0;
$result['message'] = 'Something went wrong, please try again';
$itemId = trim(strip_tags(Request::get('itemId')));
$item = DB::table('items')->select('published_at', 'podcast_id')
->where('user_id', '=', Auth::user()->id)
->where('id', '=', $itemId)
->first();
if ($item) {
$items = DB::table('items')
->select('id', 'published_at')
->where('user_id', '=', Auth::user()->id)
->where('podcast_id', '=', $item->podcast_id)
->where('is_mark_as_read', '!=', 1)
->where('published_at', '<', $item->published_at)
->get();
$itemIds = [];
foreach ($items as $record) {
$record = Item::findOrFail($record->id);
$record->is_mark_as_read = 1;
$record->save();
array_push($itemIds, $record->id);
}
// @todo need to limit the item ids sent to 15 (descending order)
$result['status'] = 1;
$result['data'] = $itemIds;
$result['message'] = 'Previous items in this podcast has been marked as read';
}
return $result;
}
/**
* [markAsFavorite mark a podcast item as favorite]
* @return array
*/
public function markAsFavorite() {
$result['status'] = 0;
$result['message'] = 'Something went wrong, please try again';
$itemId = trim(strip_tags(Request::get('itemId')));
$item = DB::table('items')->select('user_id')
->where('user_id', '=', Auth::user()->id)
->where('id', '=', $itemId)
->first();
// if item with id exists in DB and is owned by the authenticated user
if ($item) {
$podcastItem = Item::findOrFail($itemId);
$result['currentValue'] = !$podcastItem->is_mark_as_favorite;
$podcastItem->is_mark_as_favorite = !$podcastItem->is_mark_as_favorite; // opposite of current value
$podcastItem->save();
$result['status'] = 1;
$result['message'] = 'This item has been updated';
}
return $result;
}
/**
* Return a view to display item search results for a given query
*/
public function search() {
$query = trim(strip_tags(Request::get('query')));
$items = DB::table('items')
->where('title', 'LIKE', "%$query%")
->orWhere('description', 'LIKE', "%$query%")
->get();
return view('items.searchresults')->with([
'items' => $items,
'query' => $query,
]);
}
} | php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Http/Controllers/PodcastController.php | app/Http/Controllers/PodcastController.php | <?php namespace App\Http\Controllers;
use App\Item;
use App\Podcast;
use Auth;
use DB;
use Feeds;
use File;
use Illuminate\Support\Facades\Redirect;
use Image;
use Request;
class PodcastController extends Controller {
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct() {
$this->middleware('auth');
}
/**
* Return the list of podcast items that are un-read
* @return view
*/
public function index() {
$items = DB::table('items')
->where('user_id', '=', Auth::user()->id)
->where('is_mark_as_read', '!=', 1)
->orderBy('published_at', 'desc')->paginate(15);
$podcasts = DB::table('podcasts')
->where('user_id', '=', Auth::user()->id)
->get();
$data = array(
'podcasts' => $podcasts,
'items' => $items,
);
return view('podcasts.list', $data);
}
/**
* Return a view to manage podcasts
* @return view
*/
public function manage() {
return view('podcasts.manage');
}
/**
* Return a view to manage settings
* @return view
*/
public function settings() {
return view('podcasts.settings');
}
/**
* Add a podcast to the database
*/
public function add() {
// create "images" directory under "public" directory if it doesn't exist
if (!File::exists(public_path() . '/images')) {
File::makeDirectory(public_path() . '/images');
}
if (Request::get('feed_url')) {
$feed = Feeds::make(Request::get('feed_url'));
$feed->force_feed(true);
$feed->handle_content_type();
$podcastName = $feed->get_title();
if ($podcastName && $podcastName != '') {
// check if the feed's first item has an audio file in its enclosure
if (strpos($feed->get_items()[0]->get_enclosure()->get_type(), 'audio') !== false) {
$podcastMachineName = strtolower(preg_replace('/\s+/', '', $podcastName));
// Save the feed thumbnail to file system and save file path to database
$img = Image::make($feed->get_image_url())->resize(100, 100);
$img->save(public_path('images/' . $podcastMachineName . '.png'));
Podcast::create([
'name' => $podcastName ? $podcastName : '',
'machine_name' => $podcastMachineName,
'feed_url' => Request::get('feed_url'),
'feed_thumbnail_location' => 'images/' . $podcastMachineName . '.png',
'user_id' => Auth::user()->id,
'web_url' => $feed->get_link(),
]);
foreach ($feed->get_items() as $item) {
Item::create([
'podcast_id' => DB::table('podcasts')
->select('id', 'machine_name')
->where('machine_name', '=', $podcastMachineName)->first()->id,
'user_id' => Auth::user()->id,
'url' => $item->get_permalink(),
'audio_url' => $item->get_enclosure()->get_link(),
'title' => $item->get_title(),
'description' => strip_tags(str_limit($item->get_description(), 100)),
'published_at' => $item->get_date('Y-m-d H:i:s'),
]);
}
// @todo Podcast was added
return redirect('podcast/player');
} else {
// @todo flash msg
return 'This doesn\'t seem to be an RSS feed with audio files. Please try another feed.';
}
} else {
// @todo Could not add podcast
return 'Sorry, this feed cannot be imported. Please try another feed';
}
} else {
// @todo use validation
return 'Invalid feed URL given.';
}
}
/**
* Delete a podcast
*/
public function delete() {
$result = ['status' => 0, 'message' => 'Something went wrong'];
if (Request::get('feedMachineName')) {
$podcastId = DB::table('podcasts')->select('id', 'machine_name')
->where('machine_name', '=', Request::get('feedMachineName'))
->where('user_id', '=', Auth::user()->id)
->first()->id;
if ($podcastId) {
$podcast = Podcast::find($podcastId);
$podcast->delete();
// @todo success
$result['status'] = 1;
$result['message'] = 'Podcast was deleted';
} else {
// @todo DB delete failed
}
} else {
// @todo invalid feed machine name given
}
return $result;
}
/**
* Return the list of favorites for a user to a view
* @return [type] [description]
*/
public function favorites() {
$items = DB::table('items')
->where('user_id', '=', Auth::user()->id)
->where('is_mark_as_favorite', '!=', 0)
->orderBy('published_at', 'desc')->paginate(15);
$data = array(
'items' => $items,
);
return view('podcasts.favorites', $data);
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Http/Controllers/Auth/AuthController.php | app/Http/Controllers/Auth/AuthController.php | <?php namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\Registrar;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller {
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers;
protected $redirectTo = '/podcast/player';
/**
* Create a new authentication controller instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \Illuminate\Contracts\Auth\Registrar $registrar
* @return void
*/
public function __construct(Guard $auth, Registrar $registrar)
{
$this->auth = $auth;
$this->registrar = $registrar;
$this->middleware('guest', ['except' => 'getLogout']);
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Http/Controllers/Auth/PasswordController.php | app/Http/Controllers/Auth/PasswordController.php | <?php namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\PasswordBroker;
use Illuminate\Foundation\Auth\ResetsPasswords;
class PasswordController extends Controller {
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Create a new password controller instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
* @return void
*/
public function __construct(Guard $auth, PasswordBroker $passwords)
{
$this->auth = $auth;
$this->passwords = $passwords;
$this->middleware('guest');
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Http/Middleware/Authenticate.php | app/Http/Middleware/Authenticate.php | <?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
class Authenticate {
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest())
{
if ($request->ajax())
{
return response('Unauthorized.', 401);
}
else
{
return redirect()->guest('auth/login');
}
}
return $next($request);
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Http/Middleware/RedirectIfAuthenticated.php | app/Http/Middleware/RedirectIfAuthenticated.php | <?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\RedirectResponse;
class RedirectIfAuthenticated {
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check())
{
return new RedirectResponse(url('/home'));
}
return $next($request);
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Http/Middleware/VerifyCsrfToken.php | app/Http/Middleware/VerifyCsrfToken.php | <?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
return parent::handle($request, $next);
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Services/Registrar.php | app/Services/Registrar.php | <?php namespace App\Services;
use App\User;
use Validator;
use Illuminate\Contracts\Auth\Registrar as RegistrarContract;
class Registrar implements RegistrarContract {
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
public function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
public function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Console/Kernel.php | app/Console/Kernel.php | <?php namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel {
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
'App\Console\Commands\UpdatePodcastItems',
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule) {
$schedule->command('updatePodcastItems')->twiceDaily();
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Console/Commands/Inspire.php | app/Console/Commands/Inspire.php | <?php namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
class Inspire extends Command {
/**
* The console command name.
*
* @var string
*/
protected $name = 'inspire';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Display an inspiring quote';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Console/Commands/UpdatePodcastItems.php | app/Console/Commands/UpdatePodcastItems.php | <?php namespace App\Console\Commands;
use App\Item;
use App\Podcast;
use DB;
use Feeds;
use Illuminate\Console\Command;
class UpdatePodcastItems extends Command {
/**
* The console command name.
*
* @var string
*/
protected $name = 'updatePodcastItems';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update podcast items daily at 5 AM - from RSS feeds';
/**
* Update podcast items
*
* @return mixed
*/
public function handle() {
$uniquePodcasts = DB::table('podcasts')
->select('id', 'feed_url', 'machine_name')
->groupBy('machine_name')->get();
foreach ($uniquePodcasts as $podcast) {
$usersSubscribedToThisPodcast = DB::table('podcasts')
->select('user_id', 'id as podcast_id')
->where('machine_name', '=', $podcast->machine_name)
->get();
$items = Feeds::make($podcast->feed_url)->get_items();
// Calculate 48 hours ago
$yesterday = time() - (24 * 2 * 60 * 60);
foreach ($items as $item) {
$itemPubDate = $item->get_date();
if ($item->get_date('U') > $yesterday) {
// new items
foreach ($usersSubscribedToThisPodcast as $subscriber) {
$podcastItemsCount = DB::table('items')
->select('user_id', 'title', 'podcast_id')
->where('title', '=', strip_tags($item->get_title()))
->where('user_id', '=', $subscriber->user_id)
->where('podcast_id', '=', $subscriber->podcast_id)
->count();
// if this item is not already in the DB
if ($podcastItemsCount == 0) {
Item::create([
'user_id' => $subscriber->user_id,
'title' => strip_tags($item->get_title()),
'description' => strip_tags(str_limit($item->get_description(), 100)),
'published_at' => $item->get_date('Y-m-d'),
'url' => $item->get_permalink(),
'audio_url' => $item->get_enclosure()->get_link(),
'podcast_id' => $subscriber->podcast_id,
]);
}
}
} else {
break;
}
}
}
}
} | php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Commands/Command.php | app/Commands/Command.php | <?php namespace App\Commands;
abstract class Command {
//
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Providers/ConfigServiceProvider.php | app/Providers/ConfigServiceProvider.php | <?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class ConfigServiceProvider extends ServiceProvider {
/**
* Overwrite any vendor / package configuration.
*
* This service provider is intended to provide a convenient location for you
* to overwrite any "vendor" or package configuration that you may want to
* modify before the application handles the incoming request / command.
*
* @return void
*/
public function register()
{
config([
//
]);
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Providers/RouteServiceProvider.php | app/Providers/RouteServiceProvider.php | <?php namespace App\Providers;
use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider {
/**
* This namespace is applied to the controller routes in your routes file.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
parent::boot($router);
//
}
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function map(Router $router)
{
$router->group(['namespace' => $this->namespace], function($router)
{
require app_path('Http/routes.php');
});
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Providers/EventServiceProvider.php | app/Providers/EventServiceProvider.php | <?php namespace App\Providers;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider {
/**
* The event handler mappings for the application.
*
* @var array
*/
protected $listen = [
'event.name' => [
'EventListener',
],
];
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
//
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Providers/BusServiceProvider.php | app/Providers/BusServiceProvider.php | <?php namespace App\Providers;
use Illuminate\Bus\Dispatcher;
use Illuminate\Support\ServiceProvider;
class BusServiceProvider extends ServiceProvider {
/**
* Bootstrap any application services.
*
* @param \Illuminate\Bus\Dispatcher $dispatcher
* @return void
*/
public function boot(Dispatcher $dispatcher)
{
$dispatcher->mapUsing(function($command)
{
return Dispatcher::simpleMapping(
$command, 'App\Commands', 'App\Handlers\Commands'
);
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Providers/AppServiceProvider.php | app/Providers/AppServiceProvider.php | <?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider {
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register any application services.
*
* This service provider is a great spot to register your various container
* bindings with the application. As you can see, we are registering our
* "Registrar" implementation here. You can add your own bindings too!
*
* @return void
*/
public function register()
{
$this->app->bind(
'Illuminate\Contracts\Auth\Registrar',
'App\Services\Registrar'
);
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/app/Events/Event.php | app/Events/Event.php | <?php namespace App\Events;
abstract class Event {
//
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/bootstrap/app.php | bootstrap/app.php | <?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$app->singleton(
'Illuminate\Contracts\Http\Kernel',
'App\Http\Kernel'
);
$app->singleton(
'Illuminate\Contracts\Console\Kernel',
'App\Console\Kernel'
);
$app->singleton(
'Illuminate\Contracts\Debug\ExceptionHandler',
'App\Exceptions\Handler'
);
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/bootstrap/autoload.php | bootstrap/autoload.php | <?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Composer Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Include The Compiled Class File
|--------------------------------------------------------------------------
|
| To dramatically increase your application's performance, you may use a
| compiled class file which contains all of the classes commonly used
| by a request. The Artisan "optimize" is used to create this file.
|
*/
$compiledPath = __DIR__.'/../vendor/compiled.php';
if (file_exists($compiledPath))
{
require $compiledPath;
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/tests/TestCase.php | tests/TestCase.php | <?php
class TestCase extends Illuminate\Foundation\Testing\TestCase {
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
return $app;
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/tests/ExampleTest.php | tests/ExampleTest.php | <?php
class ExampleTest extends TestCase {
/**
* A basic functional test example.
*
* @return void
*/
public function testBasicExample()
{
$response = $this->call('GET', '/');
$this->assertEquals(200, $response->getStatusCode());
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/public/index.php | public/index.php | <?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylorotwell@gmail.com>
*/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
|
*/
require __DIR__.'/../bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/config/app.php | config/app.php | <?php
return [
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => env('APP_DEBUG'),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => getenv('APP_URL') ?: 'http://podcast.local',
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY', 'someRandomString'),
'cipher' => MCRYPT_RIJNDAEL_128,
/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/
'log' => 'daily',
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Bus\BusServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
'Illuminate\Routing\ControllerServiceProvider',
'Illuminate\Cookie\CookieServiceProvider',
'Illuminate\Database\DatabaseServiceProvider',
'Illuminate\Encryption\EncryptionServiceProvider',
'Illuminate\Filesystem\FilesystemServiceProvider',
'Illuminate\Foundation\Providers\FoundationServiceProvider',
'Illuminate\Hashing\HashServiceProvider',
'Illuminate\Mail\MailServiceProvider',
'Illuminate\Pagination\PaginationServiceProvider',
'Illuminate\Pipeline\PipelineServiceProvider',
'Illuminate\Queue\QueueServiceProvider',
'Illuminate\Redis\RedisServiceProvider',
'Illuminate\Auth\Passwords\PasswordResetServiceProvider',
'Illuminate\Session\SessionServiceProvider',
'Illuminate\Translation\TranslationServiceProvider',
'Illuminate\Validation\ValidationServiceProvider',
'Illuminate\View\ViewServiceProvider',
/*
* Application Service Providers...
*/
'App\Providers\AppServiceProvider',
'App\Providers\BusServiceProvider',
'App\Providers\ConfigServiceProvider',
'App\Providers\EventServiceProvider',
'App\Providers\RouteServiceProvider',
'willvincent\Feeds\FeedsServiceProvider',
'Barryvdh\Debugbar\ServiceProvider',
'Illuminate\View\ViewServiceProvider',
'Illuminate\Html\HtmlServiceProvider',
'Intervention\Image\ImageServiceProvider',
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
'Auth' => 'Illuminate\Support\Facades\Auth',
'Blade' => 'Illuminate\Support\Facades\Blade',
'Bus' => 'Illuminate\Support\Facades\Bus',
'Cache' => 'Illuminate\Support\Facades\Cache',
'Config' => 'Illuminate\Support\Facades\Config',
'Cookie' => 'Illuminate\Support\Facades\Cookie',
'Crypt' => 'Illuminate\Support\Facades\Crypt',
'DB' => 'Illuminate\Support\Facades\DB',
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
'Event' => 'Illuminate\Support\Facades\Event',
'File' => 'Illuminate\Support\Facades\File',
'Hash' => 'Illuminate\Support\Facades\Hash',
'Input' => 'Illuminate\Support\Facades\Input',
'Inspiring' => 'Illuminate\Foundation\Inspiring',
'Lang' => 'Illuminate\Support\Facades\Lang',
'Log' => 'Illuminate\Support\Facades\Log',
'Mail' => 'Illuminate\Support\Facades\Mail',
'Password' => 'Illuminate\Support\Facades\Password',
'Queue' => 'Illuminate\Support\Facades\Queue',
'Redirect' => 'Illuminate\Support\Facades\Redirect',
'Redis' => 'Illuminate\Support\Facades\Redis',
'Request' => 'Illuminate\Support\Facades\Request',
'Response' => 'Illuminate\Support\Facades\Response',
'Route' => 'Illuminate\Support\Facades\Route',
'Schema' => 'Illuminate\Support\Facades\Schema',
'Session' => 'Illuminate\Support\Facades\Session',
'Storage' => 'Illuminate\Support\Facades\Storage',
'URL' => 'Illuminate\Support\Facades\URL',
'Validator' => 'Illuminate\Support\Facades\Validator',
'View' => 'Illuminate\Support\Facades\View',
'Feeds' => 'willvincent\Feeds\Facades\FeedsFacade',
'Debugbar' => 'Barryvdh\Debugbar\Facade',
'Form' => 'Illuminate\Html\FormFacade',
'Html' => 'Illuminate\Html\HtmlFacade',
'Image' => 'Intervention\Image\Facades\Image',
],
];
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/config/image.php | config/image.php | <?php
return array(
/*
|--------------------------------------------------------------------------
| Image Driver
|--------------------------------------------------------------------------
|
| Intervention Image supports "GD Library" and "Imagick" to process images
| internally. You may choose one of them according to your PHP
| configuration. By default PHP's "GD Library" implementation is used.
|
| Supported: "gd", "imagick"
|
*/
'driver' => 'gd'
);
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/config/feeds.php | config/feeds.php | <?php
return [
/*
|--------------------------------------------------------------------------
| Cache Location
|--------------------------------------------------------------------------
|
| Filesystem path to use for caching, the default should be acceptable in
| most cases.
|
*/
'cache.location' => storage_path() . '/framework/cache',
/*
|--------------------------------------------------------------------------
| Cache Life
|--------------------------------------------------------------------------
|
| Life of cache, in seconds
|
*/
'cache.life' => 3600,
/*
|--------------------------------------------------------------------------
| Cache Disabled
|--------------------------------------------------------------------------
|
|
|
*/
'cache.disabled' => false,
];
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/config/session.php | config/session.php | <?php
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option controls the default session "driver" that will be used on
| requests. By default, we will use the lightweight native driver but
| you may specify any of the other wonderful drivers provided here.
|
| Supported: "file", "cookie", "database", "apc",
| "memcached", "redis", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/
'lifetime' => 120,
'expire_on_close' => false,
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it is stored. All encryption will be run
| automatically by Laravel and you can use the Session like normal.
|
*/
'encrypt' => false,
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When using the native session driver, we need a location where session
| files may be stored. A default has been set for you but a different
| location may be specified. This is only needed for file sessions.
|
*/
'files' => storage_path().'/framework/sessions',
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'connection' => null,
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table we
| should use to manage the sessions. Of course, a sensible default is
| provided for you; however, you are free to change this as needed.
|
*/
'table' => 'sessions',
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the cookie used to identify a session
| instance by ID. The name specified here will get used every time a
| new session cookie is created by the framework for every driver.
|
*/
'cookie' => 'laravel_session',
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application but you are free to change this when necessary.
|
*/
'path' => '/',
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| Here you may change the domain of the cookie used to identify a session
| in your application. This will determine which domains the cookie is
| available to in your application. A sensible default has been set.
|
*/
'domain' => null,
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you if it can not be done securely.
|
*/
'secure' => false,
];
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/config/queue.php | config/queue.php | <?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Driver
|--------------------------------------------------------------------------
|
| The Laravel queue API supports a variety of back-ends via an unified
| API, giving you convenient access to each back-end using the same
| syntax for each one. Here you may set the default queue driver.
|
| Supported: "null", "sync", "database", "beanstalkd",
| "sqs", "iron", "redis"
|
*/
'default' => env('QUEUE_DRIVER', 'sync'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection information for each server that
| is used by your application. A default configuration has been added
| for each back-end shipped with Laravel. You are free to add more.
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'expire' => 60,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'ttr' => 60,
],
'sqs' => [
'driver' => 'sqs',
'key' => 'your-public-key',
'secret' => 'your-secret-key',
'queue' => 'your-queue-url',
'region' => 'us-east-1',
],
'iron' => [
'driver' => 'iron',
'host' => 'mq-aws-us-east-1.iron.io',
'token' => 'your-token',
'project' => 'your-project-id',
'queue' => 'your-queue-name',
'encrypt' => true,
],
'redis' => [
'driver' => 'redis',
'queue' => 'default',
'expire' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control which database and table are used to store the jobs that
| have failed. You may change them to any database / table you wish.
|
*/
'failed' => [
'database' => 'mysql', 'table' => 'failed_jobs',
],
];
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/config/debugbar.php | config/debugbar.php | <?php
return array(
/*
|--------------------------------------------------------------------------
| Debugbar Settings
|--------------------------------------------------------------------------
|
| Debugbar is enabled by default, when debug is set to true in app.php.
| You can override the value by setting enable to true or false instead of null.
|
*/
'enabled' => null,
/*
|--------------------------------------------------------------------------
| Storage settings
|--------------------------------------------------------------------------
|
| DebugBar stores data for session/ajax requests.
| You can disable this, so the debugbar stores data in headers/session,
| but this can cause problems with large data collectors.
| By default, file storage (in the storage folder) is used. Redis and PDO
| can also be used. For PDO, run the package migrations first.
|
*/
'storage' => array(
'enabled' => true,
'driver' => 'file', // redis, file, pdo
'path' => storage_path() . '/debugbar', // For file driver
'connection' => null, // Leave null for default connection (Redis/PDO)
),
/*
|--------------------------------------------------------------------------
| Vendors
|--------------------------------------------------------------------------
|
| Vendor files are included by default, but can be set to false.
| This can also be set to 'js' or 'css', to only include javascript or css vendor files.
| Vendor files are for css: font-awesome (including fonts) and highlight.js (css files)
| and for js: jquery and and highlight.js
| So if you want syntax highlighting, set it to true.
| jQuery is set to not conflict with existing jQuery scripts.
|
*/
'include_vendors' => true,
/*
|--------------------------------------------------------------------------
| Capture Ajax Requests
|--------------------------------------------------------------------------
|
| The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors),
| you can use this option to disable sending the data through the headers.
|
*/
'capture_ajax' => true,
/*
|--------------------------------------------------------------------------
| DataCollectors
|--------------------------------------------------------------------------
|
| Enable/disable DataCollectors
|
*/
'collectors' => array(
'phpinfo' => true, // Php version
'messages' => true, // Messages
'time' => true, // Time Datalogger
'memory' => true, // Memory usage
'exceptions' => true, // Exception displayer
'log' => true, // Logs from Monolog (merged in messages if enabled)
'db' => true, // Show database (PDO) queries and bindings
'views' => true, // Views with their data
'route' => true, // Current route information
'laravel' => false, // Laravel version and environment
'events' => false, // All events fired
'default_request' => false, // Regular or special Symfony request logger
'symfony_request' => true, // Only one can be enabled..
'mail' => true, // Catch mail messages
'logs' => false, // Add the latest log messages
'files' => false, // Show the included files
'config' => false, // Display config settings
'auth' => false, // Display Laravel authentication status
'session' => false, // Display session data in a separate tab
),
/*
|--------------------------------------------------------------------------
| Extra options
|--------------------------------------------------------------------------
|
| Configure some DataCollectors
|
*/
'options' => array(
'auth' => array(
'show_name' => false, // Also show the users name/email in the debugbar
),
'db' => array(
'with_params' => true, // Render SQL with the parameters substituted
'timeline' => false, // Add the queries to the timeline
'backtrace' => false, // EXPERIMENTAL: Use a backtrace to find the origin of the query in your files.
'explain' => array( // EXPERIMENTAL: Show EXPLAIN output on queries
'enabled' => false,
'types' => array('SELECT'), // array('SELECT', 'INSERT', 'UPDATE', 'DELETE'); for MySQL 5.6.3+
),
'hints' => true, // Show hints for common mistakes
),
'mail' => array(
'full_log' => false
),
'views' => array(
'data' => false, //Note: Can slow down the application, because the data can be quite large..
),
'route' => array(
'label' => true // show complete route on bar
),
'logs' => array(
'file' => null
),
),
/*
|--------------------------------------------------------------------------
| Inject Debugbar in Response
|--------------------------------------------------------------------------
|
| Usually, the debugbar is added just before <body>, by listening to the
| Response after the App is done. If you disable this, you have to add them
| in your template yourself. See http://phpdebugbar.com/docs/rendering.html
|
*/
'inject' => true,
/*
|--------------------------------------------------------------------------
| DebugBar route prefix
|--------------------------------------------------------------------------
|
| Sometimes you want to set route prefix to be used by DebugBar to load
| its resources from. Usually the need comes from misconfigured web server or
| from trying to overcome bugs like this: http://trac.nginx.org/nginx/ticket/97
|
*/
'route_prefix' => '_debugbar',
);
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/config/cache.php | config/cache.php | <?php
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
*/
'stores' => [
'apc' => [
'driver' => 'apc'
],
'array' => [
'driver' => 'array'
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path().'/framework/cache',
],
'memcached' => [
'driver' => 'memcached',
'servers' => [
[
'host' => '127.0.0.1', 'port' => 11211, 'weight' => 100
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/
'prefix' => 'laravel',
];
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/config/view.php | config/view.php | <?php
return [
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most templating systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views. Of course
| the usual Laravel view path has already been registered for you.
|
*/
'paths' => [
realpath(base_path('resources/views'))
],
/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the storage
| directory. However, as usual, you are free to change this value.
|
*/
'compiled' => realpath(storage_path().'/framework/views'),
];
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/config/database.php | config/database.php | <?php
return [
/*
|--------------------------------------------------------------------------
| PDO Fetch Style
|--------------------------------------------------------------------------
|
| By default, database results will be returned as instances of the PHP
| stdClass object; however, you may desire to retrieve records in an
| array format for simplicity. Here you can tweak the fetch style.
|
*/
'fetch' => PDO::FETCH_CLASS,
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => 'mysql',
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => storage_path().'/database.sqlite',
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'prefix' => '',
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'cluster' => false,
'default' => [
'host' => '127.0.0.1',
'port' => 6379,
'database' => 0,
],
],
];
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/config/services.php | config/services.php | <?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Stripe, Mailgun, Mandrill, and others. This file provides a sane
| default location for this type of information, allowing packages
| to have a conventional place to find your various credentials.
|
*/
'mailgun' => [
'domain' => '',
'secret' => '',
],
'mandrill' => [
'secret' => '',
],
'ses' => [
'key' => '',
'secret' => '',
'region' => 'us-east-1',
],
'stripe' => [
'model' => 'App\User',
'secret' => '',
],
];
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/config/filesystems.php | config/filesystems.php | <?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. A "local" driver, as well as a variety of cloud
| based drivers are available for your choosing. Just store away!
|
| Supported: "local", "s3", "rackspace"
|
*/
'default' => 'local',
/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/
'cloud' => 's3',
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path().'/app',
],
's3' => [
'driver' => 's3',
'key' => 'your-key',
'secret' => 'your-secret',
'region' => 'your-region',
'bucket' => 'your-bucket',
],
'rackspace' => [
'driver' => 'rackspace',
'username' => 'your-username',
'key' => 'your-key',
'container' => 'your-container',
'endpoint' => 'https://identity.api.rackspacecloud.com/v2.0/',
'region' => 'IAD',
'url_type' => 'publicURL'
],
],
];
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/config/mail.php | config/mail.php | <?php
return [
/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log"
|
*/
'driver' => env('MAIL_DRIVER', 'smtp'),
/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/
'port' => env('MAIL_PORT', 587),
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => ['address' => null, 'name' => null],
/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/
'encryption' => 'tls',
/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/
'username' => env('MAIL_USERNAME'),
/*
|--------------------------------------------------------------------------
| SMTP Server Password
|--------------------------------------------------------------------------
|
| Here you may set the password required by your SMTP server to send out
| messages from your application. This will be given to the server on
| connection so that the application will be able to send messages.
|
*/
'password' => env('MAIL_PASSWORD'),
/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/
'sendmail' => '/usr/sbin/sendmail -bs',
/*
|--------------------------------------------------------------------------
| Mail "Pretend"
|--------------------------------------------------------------------------
|
| When this option is enabled, e-mail will not actually be sent over the
| web and will instead be written to your application's logs files so
| you may inspect the message. This is great for local development.
|
*/
'pretend' => false,
];
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/config/compile.php | config/compile.php | <?php
return [
/*
|--------------------------------------------------------------------------
| Additional Compiled Classes
|--------------------------------------------------------------------------
|
| Here you may specify additional classes to include in the compiled file
| generated by the `artisan optimize` command. These should be classes
| that are included on basically every request into the application.
|
*/
'files' => [
realpath(__DIR__.'/../app/Providers/AppServiceProvider.php'),
realpath(__DIR__.'/../app/Providers/BusServiceProvider.php'),
realpath(__DIR__.'/../app/Providers/ConfigServiceProvider.php'),
realpath(__DIR__.'/../app/Providers/EventServiceProvider.php'),
realpath(__DIR__.'/../app/Providers/RouteServiceProvider.php'),
],
/*
|--------------------------------------------------------------------------
| Compiled File Providers
|--------------------------------------------------------------------------
|
| Here you may list service providers which define a "compiles" function
| that returns additional files that should be compiled, providing an
| easy way to get common files from any packages you are utilizing.
|
*/
'providers' => [
//
],
];
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/config/auth.php | config/auth.php | <?php
return [
/*
|--------------------------------------------------------------------------
| Default Authentication Driver
|--------------------------------------------------------------------------
|
| This option controls the authentication driver that will be utilized.
| This driver manages the retrieval and authentication of the users
| attempting to get access to protected areas of your application.
|
| Supported: "database", "eloquent"
|
*/
'driver' => 'eloquent',
/*
|--------------------------------------------------------------------------
| Authentication Model
|--------------------------------------------------------------------------
|
| When using the "Eloquent" authentication driver, we need to know which
| Eloquent model should be used to retrieve your users. Of course, it
| is often just the "User" model but you may use whatever you like.
|
*/
'model' => 'App\User',
/*
|--------------------------------------------------------------------------
| Authentication Table
|--------------------------------------------------------------------------
|
| When using the "Database" authentication driver, we need to know which
| table should be used to retrieve your users. We have chosen a basic
| default value but you may easily change it to any table you like.
|
*/
'table' => 'users',
/*
|--------------------------------------------------------------------------
| Password Reset Settings
|--------------------------------------------------------------------------
|
| Here you may set the options for resetting passwords including the view
| that is your password reset e-mail. You can also set the name of the
| table that maintains all of the reset tokens for your application.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'password' => [
'email' => 'emails.password',
'table' => 'password_resets',
'expire' => 60,
],
];
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Srikanth-AD/Podcastwala | https://github.com/Srikanth-AD/Podcastwala/blob/9444ad9fddbd6999606c8828345f871b8bff6348/database/seeds/DatabaseSeeder.php | database/seeds/DatabaseSeeder.php | <?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
// $this->call('UserTableSeeder');
}
}
| php | MIT | 9444ad9fddbd6999606c8828345f871b8bff6348 | 2026-01-05T04:39:48.576378Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.