Skip to content

Commit

Permalink
Modifies lib to namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
heiglandreas committed May 25, 2016
1 parent 94962d1 commit 4d71925
Show file tree
Hide file tree
Showing 19 changed files with 605 additions and 914 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
29 changes: 29 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "org_heigl/ghostscript",
"description": "A PHP-Wrapper around the Ghostscript-CLI",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Andreas Heigl",
"email": "[email protected]"
}
],
"autoload" : {
"psr-4" : {
"Org_Heigl\\Ghostscript\\" : "src/"
}
},
"autoload-dev" : {
"psr-4" : {
"Org_Heigl\\GhostscriptTest\\" : "tests/"
}
},
"require-dev": {
"phpunit/phpunit": "^4.8||^5.3",
"fabpot/php-cs-fixer": "^1.11"
},
"scripts" : {
"csfix" : "./vendor/bin/php-cs-fixer fix . --level=psr2"
}
}
27 changes: 27 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./vendor/autoload.php">
<testsuite name="Org_Heigl\Ghostscript Test-Suite">
<directory>./tests</directory>
</testsuite>

<groups>
<exclude>
<group>disable</group>
</exclude>
</groups>

<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>

<logging>
<!--
Adapt these paths to your special needs
-->
<log type="coverage-html" target="build/phpunit/coverage" charset="UTF-8"
yui="true" highlight="false"
lowUpperBound="35" highLowerBound="70"/>
</logging>
</phpunit>
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
/**
* $Id$
*
* Copyright (c) 2008-2009 Andreas Heigl<[email protected]>
* Copyright (c) Andreas Heigl<[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -22,51 +20,40 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @category Org_Heigl
* @package Org_Heigl_Ghostscript
* @subpackage Devices
* @author Andreas Heigl <[email protected]>
* @copyright 2008-2009 Andreas Heigl
* @copyright Andreas Heigl
* @license http://www.opensource.org/licenses/mit-license.php MIT-License
* @version SVN: $Revision$
* @since 04.06.2009
*/

namespace Org_Heigl\Ghostscript\Device;

/**
* This abstract class defines interfaces for Ghostscript devices
*
* @category Org_Heigl
* @package Org_Heigl_Ghostscript
* @subpackage Devices
* @author Andreas Heigl <[email protected]>
* @copyright 2008-2009 Andreas Heigl
* @license http://www.opensource.org/licenses/mit-license.php MIT-License
* @version SVN: $Revision$
* @since 04.06.2009
*/
abstract class Org_Heigl_Ghostscript_Device_Abstract
interface DeviceInterface
{
/**
* Get the name of the device as Ghostscript expects it
*
* @return string
*/
abstract public function getDevice ();
public function getDevice();

/**
* Get the complete parameter string for this device
*
* @return string
*/
public function getParameterString () {
return '';
}
public function getParameterString();

/**
* Get the ending of the file
*
* @return string
*/
abstract function getFileEnding ();

}
public function getFileEnding();
}
65 changes: 29 additions & 36 deletions src/Org/Heigl/Ghostscript/Device/Jpeg.php → src/Device/Jpeg.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
/**
* $Id$
*
* Copyright (c) 2008-2009 Andreas Heigl<[email protected]>
* Copyright (c) Andreas Heigl<[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -22,39 +20,37 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @category Org_Heigl
* @package Org_Heigl_Ghostscript
* @subpackage Devices
* @author Andreas Heigl <[email protected]>
* @copyright 2008-2009 Andreas Heigl
* @copyright Andreas Heigl
* @license http://www.opensource.org/licenses/mit-license.php MIT-License
* @version SVN: $Revision$
* @since 04.06.2009
*/

/** Org_Heigl_Ghostscript_Device_Abstract */
require_once 'Org/Heigl/Ghostscript/Device/Abstract.php';

namespace Org_Heigl\Ghostscript\Device;

/**
* This abstract class defines interfaces for Ghostscript devices
*
* @category Org_Heigl
* @package Org_Heigl_Ghostscript
* @subpackage Devices
* @author Andreas Heigl <[email protected]>
* @copyright 2008-2009 Andreas Heigl
* @license http://www.opensource.org/licenses/mit-license.php MIT-License
* @version SVN: $Revision$
* @since 04.06.2009
*/
class Org_Heigl_Ghostscript_Device_Jpeg extends Org_Heigl_Ghostscript_Device_Abstract
class Jpeg implements DeviceInterface
{
/**
* The quality of the JPEG
*
* @var int $_quality
*/
protected $_quality = 75;

/**
* Get the name of the device as Ghostscript expects it
*
* @return string
*/
public function getDevice () {
public function getDevice()
{
return 'jpeg';
}

Expand All @@ -63,11 +59,12 @@ public function getDevice () {
*
* @return string
*/
public function getParameterString () {
public function getParameterString()
{
$string = '';
$string .= ' -sDEVICE=' . $this -> getDevice ();
$string .= ' -dJPEGQ=' . $this -> getQuality ();
$string .= ' -dQFactor=' . 1 / 100 * $this -> getQuality ();
$string .= ' -sDEVICE=' . $this -> getDevice();
$string .= ' -dJPEGQ=' . $this -> getQuality();
$string .= ' -dQFactor=' . 1 / 100 * $this -> getQuality();

return $string;
}
Expand All @@ -79,16 +76,17 @@ public function getParameterString () {
*
* @param int $quality
*
* @return Org_Heigl_Ghostscript_Device_Jpeg
* @return Jpeg
*/
public function setQuality ( $quality ) {
public function setQuality($quality)
{
$quality = (int) $quality;

if ( 100 < $quality ) {
if (100 < $quality) {
$quality = 100;
}

if ( 0 > $quality ) {
if (0 > $quality) {
$quality = 0;
}

Expand All @@ -102,23 +100,18 @@ public function setQuality ( $quality ) {
*
* @return int
*/
public function getQuality () {
public function getQuality()
{
return $this -> _quality;
}

/**
* The quality of the JPEG
*
* @var int $_quality
*/
protected $_quality = 75;

/**
* Get the file ending
*
* @return string
*/
public function getFileEnding () {
public function getFileEnding()
{
return 'jpeg';
}
}
}
Loading

0 comments on commit 4d71925

Please sign in to comment.