Skip to content

Commit

Permalink
Apply php-cs-fixer fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
j3j5 committed Sep 28, 2017
1 parent 611a6ef commit 7df3cfc
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 50 deletions.
13 changes: 6 additions & 7 deletions src/Definitions/AbstractDefinition.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Thenextweb\Definitions;

use Carbon\Carbon;
Expand Down Expand Up @@ -52,7 +53,7 @@ public function setDescription($description)

public function setOrganizationName($organizationName)
{
$this->attributes['organizationName'] =$organizationName;
$this->attributes['organizationName'] = $organizationName;

return $this;
}
Expand Down Expand Up @@ -90,7 +91,7 @@ public function setAssociatedStoreIdentifier($associatedStoreIdentifier)
{
$this->attributes['associatedStoreIdentifiers'] = is_array($associatedStoreIdentifier)
? $associatedStoreIdentifier
: array($associatedStoreIdentifier);
: [$associatedStoreIdentifier];

return $this;
}
Expand Down Expand Up @@ -411,7 +412,6 @@ public function getSecondaryFields()
return $this->getStructure('secondaryFields');
}


public function setTransitType($transitType)
{
$this->attributes['transitType'] = $transitType;
Expand Down Expand Up @@ -444,7 +444,7 @@ public function getPassDefinition()

return $array;
}

/**
* Returns an array representation of the definition compatible with PassKit Package Format
*/
Expand All @@ -465,12 +465,11 @@ public function toArray()
if (array_key_exists('relevantDate', $data) && $data['relevantDate'] instanceof Carbon) {
$data['relevantDate'] = $data['relevantDate']->format(DATE_W3C);
}

if (array_key_exists('structure', $data)) {
$structure = $data['structure'];
unset($data['structure']);


foreach ($structure as $key => $value) {
if (!$value instanceof Collection) {
continue;
Expand Down Expand Up @@ -615,4 +614,4 @@ public function rules()
//'nfc.encryptionPublicKey',
];
}
}
}
3 changes: 1 addition & 2 deletions src/Definitions/BoardingPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

namespace Thenextweb\Definitions;


class BoardingPass extends AbstractDefinition
{
protected $style = 'boardingPass';
}
}
3 changes: 1 addition & 2 deletions src/Definitions/Coupon.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

namespace Thenextweb\Definitions;


class Coupon extends AbstractDefinition
{
protected $style = 'coupon';
}
}
3 changes: 1 addition & 2 deletions src/Definitions/DefinitionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

namespace Thenextweb\Definitions;


interface DefinitionInterface
{
/**
* @return array
*/
public function getPassDefinition();
}
}
1 change: 0 additions & 1 deletion src/Definitions/Dictionary/Barcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Thenextweb\Definitions\Dictionary;


use Illuminate\Support\Fluent;

class Barcode extends Fluent
Expand Down
3 changes: 1 addition & 2 deletions src/Definitions/Dictionary/Beacon.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

use Illuminate\Support\Fluent;


class Beacon extends Fluent
{
/**
Expand Down Expand Up @@ -56,4 +55,4 @@ public function setRelevantText($relevantText)

return $this;
}
}
}
3 changes: 1 addition & 2 deletions src/Definitions/Dictionary/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Thenextweb\Definitions\Dictionary;


use Carbon\Carbon;

class Date extends Field
Expand All @@ -26,7 +25,7 @@ class Date extends Field
public function setDateStyle($dateStyle)
{
$this->attributes['dateStyle'] = $dateStyle;

return $this;
}

Expand Down
1 change: 0 additions & 1 deletion src/Definitions/Dictionary/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Thenextweb\Definitions\Dictionary;


use Illuminate\Support\Fluent;

class Field extends Fluent
Expand Down
3 changes: 1 addition & 2 deletions src/Definitions/Dictionary/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Thenextweb\Definitions\Dictionary;


use Illuminate\Support\Fluent;

class Location extends Fluent
Expand Down Expand Up @@ -40,4 +39,4 @@ public function setRelevantText($relevantText)

return $this;
}
}
}
1 change: 0 additions & 1 deletion src/Definitions/Dictionary/Nfc.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Thenextweb\Definitions\Dictionary;


use Illuminate\Support\Fluent;

class Nfc extends Fluent
Expand Down
1 change: 0 additions & 1 deletion src/Definitions/Dictionary/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Thenextweb\Definitions\Dictionary;


class Number extends Field
{
const STYLE_DECIMAL = 'PKNumberStyleDecimal';
Expand Down
3 changes: 1 addition & 2 deletions src/Definitions/EventTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

namespace Thenextweb\Definitions;


class EventTicket extends AbstractDefinition
{
protected $style = 'eventTicket';
}
}
3 changes: 1 addition & 2 deletions src/Definitions/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

namespace Thenextweb\Definitions;


class Generic extends AbstractDefinition
{
protected $style = 'generic';
}
}
3 changes: 1 addition & 2 deletions src/Definitions/StoreCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

namespace Thenextweb\Definitions;


class StoreCard extends AbstractDefinition
{
protected $style = 'storeCard';
}
}
36 changes: 18 additions & 18 deletions src/PassGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function __construct($passId = false, $replaceExistent = false)
$this->certStore = file_get_contents($certPath);
} else {
throw new InvalidArgumentException(
'No certificate found on '.$certPath
'No certificate found on ' . $certPath
);
}

Expand All @@ -96,7 +96,7 @@ public function __construct($passId = false, $replaceExistent = false)
if (is_file($wwdrCertPath) && @openssl_x509_read(file_get_contents($wwdrCertPath))) {
$this->wwdrCertPath = $wwdrCertPath;
} else {
$errorMsg = 'No valid intermediate certificate was found on '.$wwdrCertPath.PHP_EOL;
$errorMsg = 'No valid intermediate certificate was found on ' . $wwdrCertPath . PHP_EOL;
$errorMsg .= 'The WWDR intermediate certificate must be on PEM format, ';
$errorMsg .= 'the DER version can be found at https://www.apple.com/certificateauthority/ ';
$errorMsg .= "But you'll need to export it into PEM.";
Expand All @@ -110,22 +110,22 @@ public function __construct($passId = false, $replaceExistent = false)

$this->passRelativePath = $passId;

$this->passFilename = $passId.'.pkpass';
$this->passFilename = $passId . '.pkpass';

if (Storage::disk('passgenerator')->has($this->passFilename)) {
if ($replaceExistent) {
Storage::disk('passgenerator')->delete($this->passFilename);
} else {
throw new RuntimeException(
'The file '.$this->passFilename.' already exists, try another pass_id or download.'
'The file ' . $this->passFilename . ' already exists, try another pass_id or download.'
);
}
}

$this->passRealPath = Storage::disk('passgenerator')
->getDriver()
->getAdapter()
->getPathPrefix().$this->passRelativePath;
->getPathPrefix() . $this->passRelativePath;
}

/**
Expand Down Expand Up @@ -238,7 +238,7 @@ public function create()
// Create and store the json manifest
$manifest = $this->createJsonManifest();

Storage::disk('passgenerator')->put($this->passRelativePath.'/manifest.json', $manifest);
Storage::disk('passgenerator')->put($this->passRelativePath . '/manifest.json', $manifest);

// Sign manifest with the certificate
$this->signManifest();
Expand All @@ -247,7 +247,7 @@ public function create()
$this->zipItAll();

// Get it out of the tmp folder and clean everything up
Storage::disk('passgenerator')->move($this->passRelativePath.'/'.$this->passFilename, $this->passFilename);
Storage::disk('passgenerator')->move($this->passRelativePath . '/' . $this->passFilename, $this->passFilename);

Storage::disk('passgenerator')->deleteDirectory($this->passRelativePath);

Expand All @@ -264,8 +264,8 @@ public function create()
*/
public static function getPass($passId)
{
if (Storage::disk('passgenerator')->has($passId.'.pkpass')) {
return Storage::disk('passgenerator')->get($passId.'.pkpass');
if (Storage::disk('passgenerator')->has($passId . '.pkpass')) {
return Storage::disk('passgenerator')->get($passId . '.pkpass');
}

return false;
Expand All @@ -280,8 +280,8 @@ public static function getPass($passId)
*/
public function getPassFilePath($passId)
{
if (Storage::disk('passgenerator')->has($passId.'.pkpass')) {
return $this->passRealPath.'/../'.$this->passFilename;
if (Storage::disk('passgenerator')->has($passId . '.pkpass')) {
return $this->passRealPath . '/../' . $this->passFilename;
}

return false;
Expand Down Expand Up @@ -361,9 +361,9 @@ private function removeMimeBS($emailSignature)
*/
private function signManifest()
{
$manifestPath = $this->passRealPath.'/'.$this->manifestFilename;
$manifestPath = $this->passRealPath . '/' . $this->manifestFilename;

$signaturePath = $this->passRealPath.'/'.$this->signatureFilename;
$signaturePath = $this->passRealPath . '/' . $this->signatureFilename;

$certs = [];

Expand Down Expand Up @@ -391,11 +391,11 @@ private function signManifest()
// PKCS7 returns a signature on PEM format (.p7s), we only need the DER signature so Apple does not cry.
// It turns out we are lucky since p7s format is just a Base64 encoded DER signature
// enclosed between some email headers a MIME bs, so we just need to remove some lines
$signature = Storage::disk('passgenerator')->get($this->passRelativePath.'/'.$this->signatureFilename);
$signature = Storage::disk('passgenerator')->get($this->passRelativePath . '/' . $this->signatureFilename);

$signature = $this->removeMimeBS($signature);

Storage::disk('passgenerator')->put($this->passRelativePath.'/'.$this->signatureFilename, $signature);
Storage::disk('passgenerator')->put($this->passRelativePath . '/' . $this->signatureFilename, $signature);
}

/**
Expand All @@ -405,11 +405,11 @@ private function signManifest()
*/
private function zipItAll()
{
$zipPath = $this->passRealPath.'/'.$this->passFilename;
$zipPath = $this->passRealPath . '/' . $this->passFilename;

$manifestPath = $this->passRealPath.'/'.$this->manifestFilename;
$manifestPath = $this->passRealPath . '/' . $this->manifestFilename;

$signaturePath = $this->passRealPath.'/'.$this->signatureFilename;
$signaturePath = $this->passRealPath . '/' . $this->signatureFilename;

$zip = new ZipArchive();

Expand Down
6 changes: 3 additions & 3 deletions src/PassGeneratorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ private function setupConfig()
{
//This will merge the 'default' values from the original config file of the package
// with the values of the "published" config file (in case the config files were not published)
$this->mergeConfigFrom(realpath(__DIR__.'/../config/passgenerator.php'), 'passgenerator');
$this->mergeConfigFrom(realpath(__DIR__ . '/../config/passgenerator.php'), 'passgenerator');

$this->mergeConfigFrom(realpath(__DIR__.'/../config/pass-filesystem.php'), 'filesystems');
$this->mergeConfigFrom(realpath(__DIR__ . '/../config/pass-filesystem.php'), 'filesystems');
}

/**
Expand All @@ -69,7 +69,7 @@ private function setupConfig()
private function publishAllConfigs()
{
$this->publishes([
realpath(__DIR__.'/../config/passgenerator.php') => config_path('passgenerator.php'),
realpath(__DIR__ . '/../config/passgenerator.php') => config_path('passgenerator.php'),
], 'config');
}
}

0 comments on commit 7df3cfc

Please sign in to comment.