Skip to content

Commit

Permalink
Merge pull request #238 from henriquemoody/standards
Browse files Browse the repository at this point in the history
Use PSR-2 standard
  • Loading branch information
henriquemoody committed Jan 8, 2015
2 parents 018c3fe + 9fa5f7c commit 0b3012b
Show file tree
Hide file tree
Showing 193 changed files with 415 additions and 700 deletions.
3 changes: 3 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ tools:
external_code_coverage: true
php_analyzer: true
php_changetracking: true
php_code_sniffer:
config:
standard: "PSR2"
php_cpd: true
php_mess_detector: true
php_pdepend: true
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2009-2014, Alexandre Gomes Gaigalas.
Copyright (c) 2009-2015, Alexandre Gomes Gaigalas.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
1 change: 0 additions & 1 deletion library/ExceptionIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ public function getChildren()
return new static($this->current()->getRelated($this->fullRelated), $this->fullRelated);
}
}

6 changes: 3 additions & 3 deletions library/Exceptions/AbstractGroupedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AbstractGroupedException extends AbstractNestedException
self::MODE_NEGATIVE => array(
self::NONE => 'None of there rules must pass for {{name}}',
self::SOME => 'These rules must not pass for {{name}}',
)
),
);

public function chooseTemplate()
Expand All @@ -40,11 +40,11 @@ public function getTemplate()

if (!$isEmpty && $this->template != $parentTemplate) {
return $this->template;
} if ($isEmpty && 1 === count($this->related)) {
}
if ($isEmpty && 1 === count($this->related)) {
return current($this->related)->getTemplate();
} else {
return $parentTemplate;
}
}
}

5 changes: 2 additions & 3 deletions library/Exceptions/AbstractNestedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function findRelated($path)
return $target;
}

public function getIterator($full=false, $mode=self::ITERATE_ALL)
public function getIterator($full = false, $mode = self::ITERATE_ALL)
{
$exceptionIterator = new ExceptionIterator($this, $full);

Expand All @@ -74,7 +74,7 @@ public function getFullMessage()
return implode(PHP_EOL, $message);
}

public function getRelated($full=false)
public function getRelated($full = false)
{
if (!$full && 1 === count($this->related)
&& current($this->related) instanceof AbstractNestedException) {
Expand Down Expand Up @@ -104,4 +104,3 @@ public function setRelated(array $relatedExceptions)
return $this;
}
}

3 changes: 1 addition & 2 deletions library/Exceptions/AllOfException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class AllOfException extends AbstractGroupedException
self::MODE_NEGATIVE => array(
self::NONE => 'None of these rules must pass for {{name}}',
self::SOME => 'These rules must not pass for {{name}}',
)
),
);
}

7 changes: 3 additions & 4 deletions library/Exceptions/AlnumException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ class AlnumException extends AlphaException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only letters (a-z) and digits (0-9)',
self::EXTRA => '{{name}} must contain only letters (a-z), digits (0-9) and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only letters (a-z), digits (0-9) and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain letters (a-z) or digits (0-9)',
self::EXTRA => '{{name}} must not contain letters (a-z), digits (0-9) or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain letters (a-z), digits (0-9) or "{{additionalChars}}"',
),
);
}

7 changes: 3 additions & 4 deletions library/Exceptions/AlphaException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ class AlphaException extends ValidationException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only letters (a-z)',
self::EXTRA => '{{name}} must contain only letters (a-z) and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only letters (a-z) and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain letters (a-z)',
self::EXTRA => '{{name}} must not contain letters (a-z) or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain letters (a-z) or "{{additionalChars}}"',
),
);

public function chooseTemplate()
{
return $this->getParam('additionalChars') ? static::EXTRA : static::STANDARD;
}
}

3 changes: 1 addition & 2 deletions library/Exceptions/AlwaysInvalidException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class AlwaysInvalidException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} is always valid',
)
),
);
}

3 changes: 1 addition & 2 deletions library/Exceptions/AlwaysValidException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class AlwaysValidException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} is always invalid',
)
),
);
}

3 changes: 1 addition & 2 deletions library/Exceptions/ArrException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class ArrException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be an array',
)
),
);
}

3 changes: 1 addition & 2 deletions library/Exceptions/AtLeastException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class AtLeastException extends AbstractGroupedException
self::MODE_NEGATIVE => array(
self::NONE => 'At least {{howMany}} of the {{failed}} required rules must not pass for {{name}}',
self::SOME => 'At least {{howMany}} of the {{failed}} required rules must not pass for {{name}}, only {{passed}} passed.',
)
),
);
}

3 changes: 1 addition & 2 deletions library/Exceptions/AttributeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ class AttributeException extends AbstractNestedException
self::MODE_NEGATIVE => array(
self::NOT_PRESENT => 'Attribute {{name}} must not be present',
self::INVALID => 'Attribute {{name}} must not validate',
)
),
);

public function chooseTemplate()
{
return $this->getParam('hasReference') ? static::INVALID : static::NOT_PRESENT;
}
}

2 changes: 0 additions & 2 deletions library/Exceptions/BaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@

class BaseException extends ValidationException
{

}

5 changes: 2 additions & 3 deletions library/Exceptions/BetweenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class BetweenException extends AbstractNestedException
self::BOTH => '{{name}} must not be between {{minValue}} and {{maxValue}}',
self::LOWER => '{{name}} must not be greater than {{minValue}}',
self::GREATER => '{{name}} must not be lower than {{maxValue}}',
)
),
);

public function configure($name, array $params=array())
public function configure($name, array $params = array())
{
$params['minValue'] = static::stringify($params['minValue']);
$params['maxValue'] = static::stringify($params['maxValue']);
Expand All @@ -39,4 +39,3 @@ public function chooseTemplate()
}
}
}

3 changes: 1 addition & 2 deletions library/Exceptions/BoolException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class BoolException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a boolean',
)
),
);
}

1 change: 0 additions & 1 deletion library/Exceptions/CallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
class CallException extends AbstractGroupedException
{
}

3 changes: 1 addition & 2 deletions library/Exceptions/CallbackException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class CallbackException extends AbstractNestedException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be valid',
)
),
);
}

7 changes: 3 additions & 4 deletions library/Exceptions/CharsetException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ class CharsetException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must be in the {{charset}} charset'
self::STANDARD => '{{name}} must be in the {{charset}} charset',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be in the {{charset}} charset'
)
self::STANDARD => '{{name}} must not be in the {{charset}} charset',
),
);
}

3 changes: 1 addition & 2 deletions library/Exceptions/CnhException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class CnhException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid CNH number',
)
),
);
}

6 changes: 2 additions & 4 deletions library/Exceptions/CnpjException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

class CnpjException extends ValidationException
{

public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must be a valid CNPJ number',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid CNPJ number',
)
),
);

}
}
7 changes: 3 additions & 4 deletions library/Exceptions/CntrlException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ class CntrlException extends AlphaException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only control characters',
self::EXTRA => '{{name}} must contain only control characters and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only control characters and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain control characters',
self::EXTRA => '{{name}} must not contain control characters or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain control characters or "{{additionalChars}}"',
),
);
}

1 change: 0 additions & 1 deletion library/Exceptions/ComponentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
class ComponentException extends Exception
{
}

7 changes: 3 additions & 4 deletions library/Exceptions/ConsonantException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ class ConsonantException extends AlphaException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only consonants',
self::EXTRA => '{{name}} must contain only consonants and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only consonants and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain consonants',
self::EXTRA => '{{name}} must not contain consonants or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain consonants or "{{additionalChars}}"',
),
);
}

3 changes: 1 addition & 2 deletions library/Exceptions/ContainsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class ContainsException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain the value "{{containsValue}}"',
)
),
);
}

3 changes: 1 addition & 2 deletions library/Exceptions/CountryCodeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class CountryCodeException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid country',
)
),
);
}

3 changes: 1 addition & 2 deletions library/Exceptions/CpfException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class CpfException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid CPF number',
)
),
);
}

3 changes: 1 addition & 2 deletions library/Exceptions/CreditCardException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class CreditCardException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid Credit Card number',
)
),
);
}

12 changes: 6 additions & 6 deletions library/Exceptions/DateException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ class DateException extends ValidationException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must be a valid date',
self::FORMAT => '{{name}} must be a valid date. Sample format: {{format}}'
self::FORMAT => '{{name}} must be a valid date. Sample format: {{format}}',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid date',
self::FORMAT => '{{name}} must not be a valid date in the format {{format}}'
)
self::FORMAT => '{{name}} must not be a valid date in the format {{format}}',
),
);

public function configure($name, array $params=array())
public function configure($name, array $params = array())
{
$params['format'] = date(
$params['format'], strtotime('2005-12-30 01:02:03')
$params['format'],
strtotime('2005-12-30 01:02:03')
);

return parent::configure($name, $params);
Expand All @@ -30,4 +31,3 @@ public function chooseTemplate()
return $this->getParam('format') ? static::FORMAT : static::STANDARD;
}
}

7 changes: 3 additions & 4 deletions library/Exceptions/DigitException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ class DigitException extends AlphaException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only digits (0-9)',
self::EXTRA => '{{name}} must contain only digits (0-9) and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only digits (0-9) and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain digits (0-9)',
self::EXTRA => '{{name}} must not contain digits (0-9) or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain digits (0-9) or "{{additionalChars}}"',
),
);
}

3 changes: 1 addition & 2 deletions library/Exceptions/DirectoryException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class DirectoryException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a directory',
)
),
);
}

3 changes: 1 addition & 2 deletions library/Exceptions/DomainException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class DomainException extends AbstractNestedException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid domain',
)
),
);
}

3 changes: 1 addition & 2 deletions library/Exceptions/EachException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class EachException extends AbstractNestedException
),
self::MODE_NEGATIVE => array(
self::STANDARD => 'Each item in {{name}} must not validate',
)
),
);
}

Loading

0 comments on commit 0b3012b

Please sign in to comment.