From 3611104c8c51b7ada5623a4b9c2a7c36231ebee3 Mon Sep 17 00:00:00 2001 From: sikofitt Date: Thu, 17 Nov 2016 18:32:13 -0800 Subject: [PATCH] First commit --- .bowerrc | 3 + .gitignore | 3 + bower.json | 21 ++ composer.json | 24 ++ index.html.twig | 54 +++ index.php | 110 ++++++ src/Sikofitt/PhpVersion/Entity/FileInfo.php | 117 ++++++ .../PhpVersion/Entity/ReleaseInfo.php | 349 ++++++++++++++++++ .../PhpVersion/Entity/VersionInfo.php | 119 ++++++ 9 files changed, 800 insertions(+) create mode 100644 .bowerrc create mode 100644 .gitignore create mode 100644 bower.json create mode 100644 composer.json create mode 100644 index.html.twig create mode 100644 index.php create mode 100644 src/Sikofitt/PhpVersion/Entity/FileInfo.php create mode 100644 src/Sikofitt/PhpVersion/Entity/ReleaseInfo.php create mode 100644 src/Sikofitt/PhpVersion/Entity/VersionInfo.php diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..cb1bb29 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory":"vendor/" +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..072705c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/ +vendor/ +composer.lock diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..649a293 --- /dev/null +++ b/bower.json @@ -0,0 +1,21 @@ +{ + "name": "sikofitt/php-version", + "authors": [ + "sikofitt " + ], + "description": "Pulls version information from qa.php.net/api.php", + "main": "", + "license": "GPL-3.0", + "homepage": "", + "private": true, + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "dependencies": { + "uikit": "^2.27.2" + } +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..056eed8 --- /dev/null +++ b/composer.json @@ -0,0 +1,24 @@ +{ + "name": "sikofitt/php-version", + "description": "Pulls version information from qa.php.net/api.php", + "type": "project", + "autoload": { + "psr-4": { + "Sikofitt\\":"src/Sikofitt" + } + }, + "require": { + "php": ">=7.0.0", + "guzzlehttp/guzzle": "^6.2", + "webmozart/json": "^1.2", + "doctrine/collections": "^1.3", + "twig/twig": "^1.28" + }, + "license": "GPL-3.0", + "authors": [ + { + "name": "sikofitt", + "email": "sikofitt@gmail.com" + } + ] +} diff --git a/index.html.twig b/index.html.twig new file mode 100644 index 0000000..5d65277 --- /dev/null +++ b/index.html.twig @@ -0,0 +1,54 @@ + + + + Recent Version of PHP + + + + +
+

Recent RC Version of PHP

+ {% if release is null %} +
+

No RC Releases Found.

+
+ {% else %} +
+ {% set fullVersion = release.version ~ release.release.type ~ release.release.number %} +

{{ fullVersion }}

+
+ + {% for file in release.release.files %} + +
+
+
{{ file.type|upper }}
+

php-{{ fullVersion }}.tar.{{ file.type }}

+
+
+ Download +
+
+ MD5 +
+ +
+
+
+ + {% endfor %} + +
+
+ {% endif %} +
+ + + + \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..0965aae --- /dev/null +++ b/index.php @@ -0,0 +1,110 @@ + 'https://qa.php.net/api.php', + ] +); + + +$result = $client->get( + '', + [ + 'query' => [ + 'type' => 'qa-releases', + 'format' => 'json', + ], + ] +); + + +$contents = $result + ->getBody() + ->getContents(); + +$json = new JsonDecoder(); + +$decoded = $json->decode($contents); + +$releases = new ArrayCollection(); + +foreach ($decoded as $key => $value) { + + if ('releases' === $key || 'reported' === $key) { + continue; + } + + $versionInfo = new VersionInfo(); + + $versionInfo + ->setActive($value->active) + ->setDevVersion($value->dev_version) + ->setVersion($key); + + $info = new ReleaseInfo(); + + $info->setType($value->release->type) + ->setNumber($value->release->number) + ->setVersion(isset($value->release->version) ?? "") + ->setMd5Bz2($value->release->md5_bz2) + ->setMd5Gz($value->release->md5_gz) + ->setMd5Xz($value->release->md5_xz) + ->setSha256Bz2($value->release->sha256_bz2) + ->setSha256Gz($value->release->sha256_gz) + ->setSha256Xz($value->release->sha256_xz) + ->setDate($value->release->date) + ->setBaseUrl($value->release->baseurl); + + if (isset($value->release->files)) { + foreach ($value->release->files as $fileKey => $fileValue) { + $file = new FileInfo(); + + $file->setType($fileKey) + ->setMd5($fileValue->md5) + ->setSha256($fileValue->sha256) + ->setPath($fileValue->path); + + $info->addFile($file); + } + } + + $versionInfo->setRelease($info); + + $releases->set($versionInfo->getVersion(), $versionInfo); + +} + + +$twig = new Twig_Environment( + new Twig_Loader_Filesystem([ __DIR__]) +); + +$releases = $releases->filter( + function (VersionInfo $version) { + return 0 !== $version->getRelease()->getNumber(); + } +); +if(false === $releases->isEmpty()) { + foreach ($releases as $release) + { + $twig->display('index.html.twig', ['release' => $release]); + } +} else { + $twig->display('index.html.twig', ['release' => null]); +} + + diff --git a/src/Sikofitt/PhpVersion/Entity/FileInfo.php b/src/Sikofitt/PhpVersion/Entity/FileInfo.php new file mode 100644 index 0000000..02ada10 --- /dev/null +++ b/src/Sikofitt/PhpVersion/Entity/FileInfo.php @@ -0,0 +1,117 @@ +type; + } + + /** + * @param string $type + * + * @return FileInfo + */ + public function setType(string $type): FileInfo + { + $this->type = $type; + + return $this; + } + + /** + * @return string + */ + public function getPath(): string + { + return $this->path; + } + + /** + * @param string $path + * + * @return FileInfo + */ + public function setPath(string $path): FileInfo + { + $this->path = $path; + + return $this; + } + + /** + * @return string + */ + public function getMd5(): string + { + return $this->md5; + } + + /** + * @param string $md5 + * + * @return FileInfo + */ + public function setMd5(string $md5): FileInfo + { + $this->md5 = $md5; + + return $this; + } + + /** + * @return string + */ + public function getSha256(): string + { + return $this->sha256; + } + + /** + * @param string $sha256 + * + * @return FileInfo + */ + public function setSha256(string $sha256): FileInfo + { + $this->sha256 = $sha256; + + return $this; + } + +} \ No newline at end of file diff --git a/src/Sikofitt/PhpVersion/Entity/ReleaseInfo.php b/src/Sikofitt/PhpVersion/Entity/ReleaseInfo.php new file mode 100644 index 0000000..42a5a2e --- /dev/null +++ b/src/Sikofitt/PhpVersion/Entity/ReleaseInfo.php @@ -0,0 +1,349 @@ +files = new ArrayCollection(); + } + + /** + * @return string + */ + public function getType() : String + { + return $this->type; + } + + /** + * @param string $type + * + * @return ReleaseInfo + */ + public function setType(String $type) : ReleaseInfo + { + $this->type = $type; + + return $this; + } + + /** + * @return int + */ + public function getNumber() : Int + { + return $this->number; + } + + /** + * @param int $number + * + * @return ReleaseInfo + */ + public function setNumber(Int $number) : ReleaseInfo + { + $this->number = $number; + + return $this; + } + + /** + * @return string + */ + public function getMd5Bz2() : String + { + return $this->md5Bz2; + } + + /** + * @param string $md5Bz2 + * + * @return ReleaseInfo + */ + public function setMd5Bz2(String $md5Bz2) : ReleaseInfo + { + $this->md5Bz2 = $md5Bz2; + + return $this; + } + + /** + * @return string + */ + public function getMd5Gz() : String + { + return $this->md5Gz; + } + + /** + * @param string $md5Gz + * + * @return ReleaseInfo + */ + public function setMd5Gz(String $md5Gz) : ReleaseInfo + { + $this->md5Gz = $md5Gz; + + return $this; + } + + /** + * @return string + */ + public function getMd5Xz() : String + { + return $this->md5Xz; + } + + /** + * @param string $md5Xz + * + * @return ReleaseInfo + */ + public function setMd5Xz(String $md5Xz) + { + $this->md5Xz = $md5Xz; + + return $this; + } + + /** + * @return string + */ + public function getSha256Bz2() : String + { + return $this->sha256Bz2; + } + + /** + * @param string $sha256Bz2 + * + * @return ReleaseInfo + */ + public function setSha256Bz2(String $sha256Bz2) : ReleaseInfo + { + $this->sha256Bz2 = $sha256Bz2; + + return $this; + } + + /** + * @return string + */ + public function getSha256Gz() : String + { + return $this->sha256Gz; + } + + /** + * @param string $sha256Gz + * + * @return ReleaseInfo + */ + public function setSha256Gz(String $sha256Gz) : ReleaseInfo + { + $this->sha256Gz = $sha256Gz; + + return $this; + } + + /** + * @return string + */ + public function getSha256Xz() : String + { + return $this->sha256Xz; + } + + /** + * @param string $sha256Xz + * + * @return ReleaseInfo + */ + public function setSha256Xz(String $sha256Xz) : ReleaseInfo + { + $this->sha256Xz = $sha256Xz; + + return $this; + } + + /** + * @return string + */ + public function getDate() : String + { + return $this->date; + } + + /** + * @param string $date + * + * @return ReleaseInfo + */ + public function setDate(String $date) : ReleaseInfo + { + $this->date = $date; + + return $this; + } + + /** + * @return string + */ + public function getBaseUrl() : String + { + return $this->baseUrl; + } + + /** + * @param string $baseUrl + * + * @return ReleaseInfo + */ + public function setBaseUrl(String $baseUrl) : ReleaseInfo + { + $this->baseUrl = $baseUrl; + + return $this; + } + + /** + * @return string + */ + public function getVersion() : String + { + return $this->version; + } + + /** + * @param string $version + * + * @return ReleaseInfo + */ + public function setVersion(String $version) : ReleaseInfo + { + $this->version = $version; + + return $this; + } + + /** + * @return ArrayCollection + */ + public function getFiles() : ArrayCollection + { + return $this->files; + } + + /** + * @param ArrayCollection $files + * + * @return ReleaseInfo + */ + public function setFiles(ArrayCollection $files) + { + $this->files = $files; + + return $this; + } + + + /** + * @param \Sikofitt\PhpVersion\Entity\FileInfo $file + * + * @return ReleaseInfo + */ + public function addFile(FileInfo $file) : ReleaseInfo + { + $this->files->add($file); + + return $this; + } + + /** + * @param \Sikofitt\PhpVersion\Entity\FileInfo $file + * + * @return ReleaseInfo + */ + public function removeFile(FileInfo $file) : ReleaseInfo + { + $this->files->removeElement($file); + + return $this; + } + +} \ No newline at end of file diff --git a/src/Sikofitt/PhpVersion/Entity/VersionInfo.php b/src/Sikofitt/PhpVersion/Entity/VersionInfo.php new file mode 100644 index 0000000..03503ca --- /dev/null +++ b/src/Sikofitt/PhpVersion/Entity/VersionInfo.php @@ -0,0 +1,119 @@ +version; + } + + /** + * @param string $version + * + * @return VersionInfo + */ + public function setVersion(string $version): VersionInfo + { + $this->version = $version; + + return $this; + } + + /** + * @return boolean + */ + public function isActive(): bool + { + return $this->active; + } + + /** + * @param boolean $active + * + * @return VersionInfo + */ + public function setActive(bool $active): VersionInfo + { + $this->active = $active; + + return $this; + } + + /** + * @return ReleaseInfo + */ + public function getRelease(): ReleaseInfo + { + return $this->release; + } + + /** + * @param ReleaseInfo $release + * + * @return VersionInfo + */ + public function setRelease(ReleaseInfo $release): VersionInfo + { + $this->release = $release; + + return $this; + } + + /** + * @return string + */ + public function getDevVersion(): string + { + return $this->devVersion; + } + + /** + * @param string $devVersion + * + * @return VersionInfo + */ + public function setDevVersion(string $devVersion): VersionInfo + { + $this->devVersion = $devVersion; + + return $this; + } + + +} \ No newline at end of file