Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
endroid committed Sep 19, 2017
1 parent 5f7bdac commit 899135a
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 70 deletions.
7 changes: 4 additions & 3 deletions src/Bundle/QrCodeBundle/Controller/QrCodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ class QrCodeController extends Controller
* @Route("/{text}.{extension}", name="endroid_qrcode_generate", requirements={"text"="[\w\W]+"})
*
* @param Request $request
* @param string $text
* @param string $extension
* @param string $text
* @param string $extension
*
* @return Response
*/
public function generateAction(Request $request, $text, $extension)
Expand All @@ -48,7 +49,7 @@ public function generateAction(Request $request, $text, $extension)
public function twigFunctionsAction()
{
return [
'message' => 'QR Code'
'message' => 'QR Code',
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use Endroid\QrCode\ErrorCorrectionLevel;
use Endroid\QrCode\LabelAlignment;
use Endroid\QrCode\QrCode;
use Predis\Response\Error;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
Expand Down
9 changes: 5 additions & 4 deletions src/Factory/QrCodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class QrCodeFactory
'label_font_path',
'label_alignment',
'label_margin',
'validate_result'
'validate_result',
];

/**
Expand All @@ -53,7 +53,7 @@ class QrCodeFactory
protected $optionsResolver;

/**
* @param array $defaultOptions
* @param array $defaultOptions
* @param WriterRegistryInterface $writerRegistry
*/
public function __construct(array $defaultOptions = [], WriterRegistryInterface $writerRegistry = null)
Expand All @@ -64,7 +64,8 @@ public function __construct(array $defaultOptions = [], WriterRegistryInterface

/**
* @param string $text
* @param array $options
* @param array $options
*
* @return QrCode
*/
public function create($text = '', array $options = [])
Expand All @@ -80,7 +81,7 @@ public function create($text = '', array $options = [])

foreach ($this->definedOptions as $option) {
if (isset($options[$option])) {
if ($option === 'writer') {
if ('writer' === $option) {
$options['writer_by_name'] = $options[$option];
$option = 'writer_by_name';
}
Expand Down
49 changes: 38 additions & 11 deletions src/QrCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class QrCode implements QrCodeInterface
{
const LABEL_FONT_PATH_DEFAULT = __DIR__ . '/../assets/noto_sans.otf';
const LABEL_FONT_PATH_DEFAULT = __DIR__.'/../assets/noto_sans.otf';

/**
* @var string
Expand All @@ -39,7 +39,7 @@ class QrCode implements QrCodeInterface
protected $foregroundColor = [
'r' => 0,
'g' => 0,
'b' => 0
'b' => 0,
];

/**
Expand All @@ -48,7 +48,7 @@ class QrCode implements QrCodeInterface
protected $backgroundColor = [
'r' => 255,
'g' => 255,
'b' => 255
'b' => 255,
];

/**
Expand Down Expand Up @@ -131,6 +131,7 @@ public function __construct($text = '')

/**
* @param string $text
*
* @return $this
*/
public function setText($text)
Expand All @@ -150,6 +151,7 @@ public function getText()

/**
* @param int $size
*
* @return $this
*/
public function setSize($size)
Expand All @@ -169,6 +171,7 @@ public function getSize()

/**
* @param int $margin
*
* @return $this
*/
public function setMargin($margin)
Expand All @@ -188,6 +191,7 @@ public function getMargin()

/**
* @param array $foregroundColor
*
* @return $this
*/
public function setForegroundColor($foregroundColor)
Expand All @@ -207,6 +211,7 @@ public function getForegroundColor()

/**
* @param array $backgroundColor
*
* @return $this
*/
public function setBackgroundColor($backgroundColor)
Expand All @@ -226,6 +231,7 @@ public function getBackgroundColor()

/**
* @param string $encoding
*
* @return $this
*/
public function setEncoding($encoding)
Expand All @@ -245,6 +251,7 @@ public function getEncoding()

/**
* @param string $errorCorrectionLevel
*
* @return $this
*/
public function setErrorCorrectionLevel($errorCorrectionLevel)
Expand All @@ -264,15 +271,17 @@ public function getErrorCorrectionLevel()

/**
* @param string $logoPath
*
* @return $this
*
* @throws InvalidPathException
*/
public function setLogoPath($logoPath)
{
$logoPath = realpath($logoPath);

if (!is_file($logoPath)) {
throw new InvalidPathException('Invalid logo path: ' . $logoPath);
throw new InvalidPathException('Invalid logo path: '.$logoPath);
}

$this->logoPath = $logoPath;
Expand All @@ -290,6 +299,7 @@ public function getLogoPath()

/**
* @param int $logoWidth
*
* @return $this
*/
public function setLogoWidth($logoWidth)
Expand All @@ -309,29 +319,30 @@ public function getLogoWidth()

/**
* @param string $label
* @param int $labelFontSize
* @param int $labelFontSize
* @param string $labelFontPath
* @param string $labelAlignment
* @param array $labelMargin
* @param array $labelMargin
*
* @return $this
*/
public function setLabel($label, $labelFontSize = null, $labelFontPath = null, $labelAlignment = null, $labelMargin = null)
{
$this->label = $label;

if ($labelFontSize !== null) {
if (null !== $labelFontSize) {
$this->setLabelFontSize($labelFontSize);
}

if ($labelFontPath !== null) {
if (null !== $labelFontPath) {
$this->setLabelFontPath($labelFontPath);
}

if ($labelAlignment !== null) {
if (null !== $labelAlignment) {
$this->setLabelAlignment($labelAlignment);
}

if ($labelMargin !== null) {
if (null !== $labelMargin) {
$this->setLabelMargin($labelMargin);
}

Expand All @@ -348,6 +359,7 @@ public function getLabel()

/**
* @param int $labelFontSize
*
* @return $this
*/
public function setLabelFontSize($labelFontSize)
Expand All @@ -367,15 +379,17 @@ public function getLabelFontSize()

/**
* @param string $labelFontPath
*
* @return $this
*
* @throws InvalidPathException
*/
public function setLabelFontPath($labelFontPath)
{
$labelFontPath = realpath($labelFontPath);

if (!is_file($labelFontPath)) {
throw new InvalidPathException('Invalid label font path: ' . $labelFontPath);
throw new InvalidPathException('Invalid label font path: '.$labelFontPath);
}

$this->labelFontPath = $labelFontPath;
Expand All @@ -393,6 +407,7 @@ public function getLabelFontPath()

/**
* @param string $labelAlignment
*
* @return $this
*/
public function setLabelAlignment($labelAlignment)
Expand All @@ -412,6 +427,7 @@ public function getLabelAlignment()

/**
* @param int[] $labelMargin
*
* @return $this
*/
public function setLabelMargin(array $labelMargin)
Expand All @@ -431,6 +447,7 @@ public function getLabelMargin()

/**
* @param WriterRegistryInterface $writerRegistry
*
* @return $this
*/
public function setWriterRegistry(WriterRegistryInterface $writerRegistry)
Expand All @@ -442,6 +459,7 @@ public function setWriterRegistry(WriterRegistryInterface $writerRegistry)

/**
* @param WriterInterface $writer
*
* @return $this
*/
public function setWriter(WriterInterface $writer)
Expand All @@ -453,6 +471,7 @@ public function setWriter(WriterInterface $writer)

/**
* @param WriterInterface $name
*
* @return WriterInterface
*/
public function getWriter($name = null)
Expand All @@ -470,7 +489,9 @@ public function getWriter($name = null)

/**
* @param string $name
*
* @return $this
*
* @throws InvalidWriterException
*/
public function setWriterByName($name)
Expand All @@ -482,6 +503,7 @@ public function setWriterByName($name)

/**
* @param string $path
*
* @return $this
*/
public function setWriterByPath($path)
Expand All @@ -495,14 +517,17 @@ public function setWriterByPath($path)

/**
* @param string $extension
*
* @return $this
*
* @throws UnsupportedExtensionException
*/
public function setWriterByExtension($extension)
{
foreach ($this->writerRegistry->getWriters() as $writer) {
if ($writer->supportsExtension($extension)) {
$this->writer = $writer;

return $this;
}
}
Expand All @@ -512,6 +537,7 @@ public function setWriterByExtension($extension)

/**
* @param bool $validateResult
*
* @return $this
*/
public function setValidateResult($validateResult)
Expand Down Expand Up @@ -555,6 +581,7 @@ public function writeFile($path)

/**
* @return string
*
* @throws InvalidWriterException
*/
public function getContentType()
Expand Down
1 change: 1 addition & 0 deletions src/QrCodeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function getValidateResult();

/**
* @param WriterRegistryInterface $writerRegistry
*
* @return mixed
*/
public function setWriterRegistry(WriterRegistryInterface $writerRegistry);
Expand Down
1 change: 0 additions & 1 deletion src/StaticWriterRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Endroid\QrCode\Writer\EpsWriter;
use Endroid\QrCode\Writer\PngWriter;
use Endroid\QrCode\Writer\SvgWriter;
use Endroid\QrCode\Writer\WriterInterface;

class StaticWriterRegistry extends WriterRegistry
{
Expand Down
Loading

0 comments on commit 899135a

Please sign in to comment.