From 4a1b26d359b884c7053a736f9e3177895e2baf42 Mon Sep 17 00:00:00 2001 From: Luis Galeas Date: Fri, 29 Nov 2019 07:50:10 +0000 Subject: [PATCH] Styles fix --- Model/Builder/Builder.php | 5 +-- Model/Filter/FilterInput.php | 4 +- Model/Filter/FilterOperators.php | 4 +- Service/JavascriptBuilders.php | 12 +----- Service/JsonQueryParser/DoctrineORMParser.php | 5 +-- Util/Validator/BuildersToMappings.php | 38 +++---------------- 6 files changed, 12 insertions(+), 56 deletions(-) diff --git a/Model/Builder/Builder.php b/Model/Builder/Builder.php index a052093..26d7ed1 100644 --- a/Model/Builder/Builder.php +++ b/Model/Builder/Builder.php @@ -52,10 +52,7 @@ public function getClassName(): string public function setClassName(string $className): self { if (!class_exists($className)) { - throw new \InvalidArgumentException(sprintf( - 'Class %s does not exist', - $className - )); + throw new \InvalidArgumentException(sprintf('Class %s does not exist', $className)); } $this->className = $className; diff --git a/Model/Filter/FilterInput.php b/Model/Filter/FilterInput.php index 91ec9d7..345f73d 100644 --- a/Model/Filter/FilterInput.php +++ b/Model/Filter/FilterInput.php @@ -70,9 +70,7 @@ public function setInputType(string $inputType): self private function validate() { if (!in_array($this->inputType, self::VALID_INPUT_TYPES)) { - throw new \InvalidArgumentException(sprintf( - '%s is not a valid input type' - ), $this->inputType); + throw new \InvalidArgumentException(sprintf('%s is not a valid input type'), $this->inputType); } } } diff --git a/Model/Filter/FilterOperators.php b/Model/Filter/FilterOperators.php index c8db27a..b9dfa4d 100644 --- a/Model/Filter/FilterOperators.php +++ b/Model/Filter/FilterOperators.php @@ -93,9 +93,7 @@ public function clearOperators(): self private function validateOperator(string $operator) { if (!in_array($operator, self::VALID_OPERATORS)) { - throw new \InvalidArgumentException(sprintf( - '%s is not a valid operator' - ), $operator); + throw new \InvalidArgumentException(sprintf('%s is not a valid operator'), $operator); } } } diff --git a/Service/JavascriptBuilders.php b/Service/JavascriptBuilders.php index a97f839..50f5be4 100644 --- a/Service/JavascriptBuilders.php +++ b/Service/JavascriptBuilders.php @@ -258,21 +258,13 @@ private function validateValueCollectionAgainstInput(FilterValueCollection $coll in_array($input->getInputType(), FilterInput::INPUT_TYPES_REQUIRE_NO_VALUES) && 0 !== $collection->getFilterValues()->count() ) { - throw new \LogicException(sprintf( - 'Too many values found, While building, Builder with ID %s and Filter with ID %s.', - $builderId, - $filterId - )); + throw new \LogicException(sprintf('Too many values found, While building, Builder with ID %s and Filter with ID %s.', $builderId, $filterId)); } if ( in_array($input->getInputType(), FilterInput::INPUT_TYPES_REQUIRE_MULTIPLE_VALUES) && 0 === $collection->getFilterValues()->count() ) { - throw new \LogicException(sprintf( - 'Not enough values found, While building, Builder with ID %s and Filter with ID %s.', - $builderId, - $filterId - )); + throw new \LogicException(sprintf('Not enough values found, While building, Builder with ID %s and Filter with ID %s.', $builderId, $filterId)); } } diff --git a/Service/JsonQueryParser/DoctrineORMParser.php b/Service/JsonQueryParser/DoctrineORMParser.php index d918715..6a7ba34 100644 --- a/Service/JsonQueryParser/DoctrineORMParser.php +++ b/Service/JsonQueryParser/DoctrineORMParser.php @@ -91,10 +91,7 @@ public function parseJsonString(string $jsonString, string $entityClassName, arr private function newParser(string $className) { if (!array_key_exists($className, $this->classNameToDoctrineParser)) { - throw new \DomainException(sprintf( - 'You have requested a Doctrine Parser for %s, but you have not defined a mapping for it in your configuration', - $className - )); + throw new \DomainException(sprintf('You have requested a Doctrine Parser for %s, but you have not defined a mapping for it in your configuration', $className)); } return $this->classNameToDoctrineParser[$className]; diff --git a/Util/Validator/BuildersToMappings.php b/Util/Validator/BuildersToMappings.php index 4c3d27d..2b2a491 100644 --- a/Util/Validator/BuildersToMappings.php +++ b/Util/Validator/BuildersToMappings.php @@ -19,19 +19,12 @@ final public static function validate(array $buildersConfig, array $classesAndMa { foreach ($buildersConfig as $builderId => $config) { if (!array_key_exists('class', $config)) { - throw new \InvalidArgumentException(sprintf( - 'Builders Configuration: Expected a class in builder with ID %s', - $builderId - )); + throw new \InvalidArgumentException(sprintf('Builders Configuration: Expected a class in builder with ID %s', $builderId)); } $builderClass = $config['class']; if (!class_exists($builderClass)) { - throw new \InvalidArgumentException(sprintf( - 'Builders Configuration: %s is not a valid class in builder with ID %s ', - $builderClass, - $builderId - )); + throw new \InvalidArgumentException(sprintf('Builders Configuration: %s is not a valid class in builder with ID %s ', $builderClass, $builderId)); } foreach ($config['result_columns'] as $column) { @@ -47,32 +40,20 @@ final public static function validate(array $buildersConfig, array $classesAndMa foreach ($config['filters'] as $filter) { if (!array_key_exists($filter['id'], $mappingProperties)) { - throw new \InvalidArgumentException(sprintf( - 'Builders Configuration: Invalid Mapping for filter with ID %s, in builder with ID %s ', - $filter['id'], - $builderId - )); + throw new \InvalidArgumentException(sprintf('Builders Configuration: Invalid Mapping for filter with ID %s, in builder with ID %s ', $filter['id'], $builderId)); } } foreach ($config['result_columns'] as $column) { if (!array_key_exists($column['column_machine_name'], $mappingProperties)) { - throw new \InvalidArgumentException(sprintf( - 'Builders Configuration: Result Column with machine name %s, in builder with ID %s, must exist in mapping for class %s ', - $column['column_machine_name'], - $builderId, - $mappingClass - )); + throw new \InvalidArgumentException(sprintf('Builders Configuration: Result Column with machine name %s, in builder with ID %s, must exist in mapping for class %s ', $column['column_machine_name'], $builderId, $mappingClass)); } } } } if (!$mappingClassFoundForBuilderClass) { - throw new \InvalidArgumentException(sprintf( - 'Builder with class %s, but no corresponding mapping for this class', - $builderClass - )); + throw new \InvalidArgumentException(sprintf('Builder with class %s, but no corresponding mapping for this class', $builderClass)); } } } @@ -93,14 +74,7 @@ final private static function validateClassHasProperty(string $className, string if (false === strpos($classProperty, '.')) { // not yet checking associations - Property Accessor can't do this if (!in_array($classProperty, $properties)) { - throw new \InvalidArgumentException( - sprintf( - 'Builder %s Bad Column Declared. Property %s is not accessible in %s.', - $builderId, - $classProperty, - $className - ) - ); + throw new \InvalidArgumentException(sprintf('Builder %s Bad Column Declared. Property %s is not accessible in %s.', $builderId, $classProperty, $className)); } } }