mirror of
https://github.com/mosbth/cimage.git
synced 2025-08-04 15:17:42 +02:00
Improved codestyle and added to start using phpcs to check code style, fix #95.
This commit is contained in:
@@ -145,7 +145,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setHeaderFields() {
|
public function setHeaderFields()
|
||||||
|
{
|
||||||
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
||||||
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
||||||
|
|
||||||
@@ -164,8 +165,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to saved file or false if not saved.
|
* @return string as path to saved file or false if not saved.
|
||||||
*/
|
*/
|
||||||
function save() {
|
public function save()
|
||||||
|
{
|
||||||
$this->cache = array();
|
$this->cache = array();
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
@@ -201,8 +202,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to cached file.
|
* @return string as path to cached file.
|
||||||
*/
|
*/
|
||||||
function updateCacheDetails() {
|
public function updateCacheDetails()
|
||||||
|
{
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
$lastModified = $this->http->getLastModified();
|
$lastModified = $this->http->getLastModified();
|
||||||
@@ -227,8 +228,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to downloaded file or false if failed.
|
* @return string as path to downloaded file or false if failed.
|
||||||
*/
|
*/
|
||||||
function download($url) {
|
public function download($url)
|
||||||
|
{
|
||||||
$this->http = new CHttpGet();
|
$this->http = new CHttpGet();
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@ Revision history
|
|||||||
v0.7.0.x (latest)
|
v0.7.0.x (latest)
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
|
* Improved codestyle and added `phpcs.xml` to start using phpcs to check code style, fix #95.
|
||||||
* Adding `composer.json` for publishing on packagist.
|
* Adding `composer.json` for publishing on packagist.
|
||||||
* Add permalink to setup for comparing images with `webroot/compare/compare.php`, fix #92.
|
* Add permalink to setup for comparing images with `webroot/compare/compare.php`, fix #92.
|
||||||
* Allow space in filename by using `urlencode()` and allow space as valid filenam character. fix #91.
|
* Allow space in filename by using `urlencode()` and allow space as valid filenam character. fix #91.
|
||||||
|
32
phpcs.xml
Normal file
32
phpcs.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="PHPCS rule set">
|
||||||
|
<description>Custom rule set.</description>
|
||||||
|
|
||||||
|
<file>.</file>
|
||||||
|
<file>test</file>
|
||||||
|
<file>autoload.php</file>
|
||||||
|
|
||||||
|
<exclude-pattern>docs/*</exclude-pattern>
|
||||||
|
<exclude-pattern>coverage/*</exclude-pattern>
|
||||||
|
<exclude-pattern>webroot/imgs.php</exclude-pattern>
|
||||||
|
<exclude-pattern>webroot/imgp.php</exclude-pattern>
|
||||||
|
<exclude-pattern>webroot/imgd.php</exclude-pattern>
|
||||||
|
<exclude-pattern>webroot/test/*</exclude-pattern>
|
||||||
|
<exclude-pattern>webroot/js/*</exclude-pattern>
|
||||||
|
<exclude-pattern>webroot/compare/*</exclude-pattern>
|
||||||
|
|
||||||
|
<arg name="encoding" value="utf-8"/>
|
||||||
|
<!--<arg name="extensions" value=".php"/>-->
|
||||||
|
<!--<arg name="colors" value="1"/>-->
|
||||||
|
<!--<arg name="warning-severity" value="5"/>-->
|
||||||
|
|
||||||
|
<rule ref="PSR2">
|
||||||
|
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" /> <exclude name="Squiz.Commenting.FileComment" />
|
||||||
|
<exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
|
||||||
|
-->
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
</ruleset>
|
@@ -3,7 +3,7 @@
|
|||||||
* A testclass
|
* A testclass
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class CImage_RemoteDownloadTest extends \PHPUnit_Framework_TestCase
|
class CImageRemoteDownloadTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* remote_whitelist
|
* remote_whitelist
|
@@ -433,7 +433,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setHeaderFields() {
|
public function setHeaderFields()
|
||||||
|
{
|
||||||
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
||||||
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
||||||
|
|
||||||
@@ -452,8 +453,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to saved file or false if not saved.
|
* @return string as path to saved file or false if not saved.
|
||||||
*/
|
*/
|
||||||
function save() {
|
public function save()
|
||||||
|
{
|
||||||
$this->cache = array();
|
$this->cache = array();
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
@@ -489,8 +490,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to cached file.
|
* @return string as path to cached file.
|
||||||
*/
|
*/
|
||||||
function updateCacheDetails() {
|
public function updateCacheDetails()
|
||||||
|
{
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
$lastModified = $this->http->getLastModified();
|
$lastModified = $this->http->getLastModified();
|
||||||
@@ -515,8 +516,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to downloaded file or false if failed.
|
* @return string as path to downloaded file or false if failed.
|
||||||
*/
|
*/
|
||||||
function download($url) {
|
public function download($url)
|
||||||
|
{
|
||||||
$this->http = new CHttpGet();
|
$this->http = new CHttpGet();
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
|
|
||||||
|
@@ -433,7 +433,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setHeaderFields() {
|
public function setHeaderFields()
|
||||||
|
{
|
||||||
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
||||||
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
||||||
|
|
||||||
@@ -452,8 +453,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to saved file or false if not saved.
|
* @return string as path to saved file or false if not saved.
|
||||||
*/
|
*/
|
||||||
function save() {
|
public function save()
|
||||||
|
{
|
||||||
$this->cache = array();
|
$this->cache = array();
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
@@ -489,8 +490,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to cached file.
|
* @return string as path to cached file.
|
||||||
*/
|
*/
|
||||||
function updateCacheDetails() {
|
public function updateCacheDetails()
|
||||||
|
{
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
$lastModified = $this->http->getLastModified();
|
$lastModified = $this->http->getLastModified();
|
||||||
@@ -515,8 +516,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to downloaded file or false if failed.
|
* @return string as path to downloaded file or false if failed.
|
||||||
*/
|
*/
|
||||||
function download($url) {
|
public function download($url)
|
||||||
|
{
|
||||||
$this->http = new CHttpGet();
|
$this->http = new CHttpGet();
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
|
|
||||||
|
@@ -433,7 +433,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setHeaderFields() {
|
public function setHeaderFields()
|
||||||
|
{
|
||||||
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
||||||
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
||||||
|
|
||||||
@@ -452,8 +453,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to saved file or false if not saved.
|
* @return string as path to saved file or false if not saved.
|
||||||
*/
|
*/
|
||||||
function save() {
|
public function save()
|
||||||
|
{
|
||||||
$this->cache = array();
|
$this->cache = array();
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
@@ -489,8 +490,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to cached file.
|
* @return string as path to cached file.
|
||||||
*/
|
*/
|
||||||
function updateCacheDetails() {
|
public function updateCacheDetails()
|
||||||
|
{
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
$lastModified = $this->http->getLastModified();
|
$lastModified = $this->http->getLastModified();
|
||||||
@@ -515,8 +516,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to downloaded file or false if failed.
|
* @return string as path to downloaded file or false if failed.
|
||||||
*/
|
*/
|
||||||
function download($url) {
|
public function download($url)
|
||||||
|
{
|
||||||
$this->http = new CHttpGet();
|
$this->http = new CHttpGet();
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user