Method getNumberValues
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getNumberValues($ruleValue, bool $isFont = false)
{
if ($ruleValue instanceof NumericValue) {
return $ruleValue;
}
Function getNumberValues
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getNumberValues($ruleValue, bool $isFont = false)
{
if ($ruleValue instanceof NumericValue) {
return $ruleValue;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Reduce the number of returns of this function 4, down to the maximum allowed 3. Open
public function normalizeMultiValues(array $ruleNames, $ruleValue): array
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
The method getNumberValues has a boolean flag argument $isFont, which is a certain sign of a Single Responsibility Principle violation. Open
public function getNumberValues($ruleValue, bool $isFont = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Rename "$normalized" which has the same name as the field declared at line 31. Open
$normalized = [];
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Rename "$normalized" which has the same name as the field declared at line 31. Open
$normalized = [];
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Rename "$normalized" which has the same name as the field declared at line 31. Open
$normalized = [];
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Rename "$normalized" which has the same name as the field declared at line 31. Open
$normalized = [];
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Add a "case default" clause to this "switch" statement. Open
switch (\count($numberValues)) {
- Read upRead up
- Exclude checks
The requirement for a final case default
clause is defensive programming. The clause should either take appropriate action, or contain
a suitable comment as to why no action is taken. Even when the switch
covers all current values of an enum
, a default case
should still be used because there is no guarantee that the enum
won't be extended.
Noncompliant Code Example
switch ($param) { //missing default clause case 0: do_something(); break; case 1: do_something_else(); break; } switch ($param) { default: // default clause should be the last one error(); break; case 0: do_something(); break; case 1: do_something_else(); break; }
Compliant Solution
switch ($param) { case 0: do_something(); break; case 1: do_something_else(); break; default: error(); break; }
See
- MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
- MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
- MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
- MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
- MISRA C:2012, 16.1 - All switch statements shall be well-formed
- MISRA C:2012, 16.4 - Every switch statement shall have a default label
- MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
- MITRE, CWE-478 - Missing Default Case in Switch Statement
- CERT, MSC01-C. - Strive for logical completeness
- CERT, MSC01-CPP. - Strive for logical completeness
Similar blocks of code found in 4 locations. Consider refactoring. Open
protected function threeValues(array $ruleNames, array $numberValues)
{
$normalized = [];
$normalized[$ruleNames[0]] = $numberValues[0];
$normalized[$ruleNames[1]] = $numberValues[1];
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 99.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
protected function fourValues(array $ruleNames, array $numberValues)
{
$normalized = [];
$normalized[$ruleNames[0]] = $numberValues[0];
$normalized[$ruleNames[1]] = $numberValues[1];
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 99.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
protected function oneValue(array $ruleNames, array $numberValues)
{
$normalized = [];
$normalized[$ruleNames[0]] = $numberValues[0];
$normalized[$ruleNames[1]] = $numberValues[0];
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 99.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
protected function twoValues(array $ruleNames, array $numberValues)
{
$normalized = [];
$normalized[$ruleNames[0]] = $numberValues[0];
$normalized[$ruleNames[1]] = $numberValues[1];
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 99.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($matchesCount >= 2) {
$multi[] = (new NumericValue())
->setUnit($matches[1][3] ?? $originalUnit)
->setValue($matches[1][2])
->setOriginal($matches[1][2] . ($matches[1][3] ?? $originalUnit))
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 98.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($matchesCount >= 3) {
$multi[] = (new NumericValue())
->setUnit($matches[2][3] ?? $originalUnit)
->setValue($matches[2][2])
->setOriginal($matches[2][2] . ($matches[2][3] ?? $originalUnit))
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 98.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ucRuleName = str_replace('-', '', ucwords($ruleName, '-'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$multi = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->convert($this->style);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[2]] = $numberValues[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected function twoValues(array $ruleNames, array $numberValues)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[1]] = $numberValues[1];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $style;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Regex used to parse numeric values.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $ruleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get number value from style.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($ruleValue instanceof NumericValue) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$originalSize = $matches[0][2];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($matches[0][3])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setOriginal($matches[3][2] . ($matches[3][3] ?? $originalUnit))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setOriginal($matches[1][2] . ($matches[1][3] ?? $originalUnit))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setIsFont($isFont)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setUnit($matches[2][3] ?? $originalUnit)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$matches = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
preg_match_all(static::$numericRegex, $value, $matches, PREG_SET_ORDER);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [$ruleName => $ruleValue];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $numberValues
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[2]] = $numberValues[2];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Four values.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[1]] = $numberValues[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[3]] = $numberValues[3];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Two values.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->twoValues($ruleNames, $numberValues);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->fourValues($ruleNames, $numberValues);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $numberValues
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->threeValues($ruleNames, $numberValues);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \YetiForcePDF\Style\Style $style
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalizerClassName = "YetiForcePDF\\Style\\Normalizer\\$ucRuleName";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new NumericValue())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setOriginal($originalSize . $originalUnit)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setOriginal($matches[2][2] . ($matches[2][3] ?? $originalUnit))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setValue($matches[3][2])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Set style.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected function oneValue(array $ruleNames, array $numberValues)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $normalized;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[0]] = $numberValues[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->convert($this->style),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $ruleValue
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (4 === $matchesCount) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $defaultUnit
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $numberValues
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected function fourValues(array $ruleNames, array $numberValues)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 2:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var Style
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getNumberValues($ruleValue, bool $isFont = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $numberValues
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[3]] = $numberValues[1];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[1]] = $numberValues[1];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function normalizeMultiValues(array $ruleNames, $ruleValue): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 4:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setStyle(Style $style)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get normalizer class name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $normalizerClassName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param NumericValue|string $ruleValue
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$matches) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$matches = [['0', '0', '0']];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setIsFont($isFont)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($matchesCount >= 2) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$multi[] = (new NumericValue())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $unit;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($matches[0][2])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* One value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string[] $ruleNames ['margin-top','margin-right','margin-bottom','margin-left']
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->oneValue($ruleNames, $numberValues);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (class_exists($normalizerClassName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
preg_match_all(static::$numericRegex, $ruleValue, $matches, PREG_SET_ORDER);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$originalUnit = 'em';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setValue($matches[2][2])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setUnit($matches[3][3] ?? $originalUnit)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $multi;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Is numeric value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[0]] = $numberValues[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[3]] = $numberValues[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $ruleNames
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $ruleValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$matchesCount = \count($matches);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setValue($matches[1][2])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $normalized;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setIsFont($isFont)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$multi[] = (new NumericValue())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$matches = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->convert($this->style);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $value value from css 12px for example
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($matches[0][3])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $ruleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $normalized;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $isFont
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[2]] = $numberValues[2];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$originalUnit = $matches[0][3];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $normalized;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $matches[0][2];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function normalize($ruleValue, string $ruleName = ''): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getNormalizerClassName(string $ruleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setUnit($originalUnit)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $normalized;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($matchesCount >= 3) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $ruleNames
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
preg_match_all(static::$numericRegex, $value, $matches, PREG_SET_ORDER);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[2]] = $numberValues[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[0]] = $numberValues[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[0]] = $numberValues[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Normalize multi number values.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$numberValues = $this->getNumberValues($ruleValue);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 3:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$unit = $defaultUnit;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getNumericValue(string $value)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array|null normalized value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $ruleNames
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->style = $style;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Three values.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setValue($originalSize)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$multi[] = (new NumericValue())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch (\count($numberValues)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->convert($this->style);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get numeric unit from css value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[1]] = $numberValues[1];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $numericRegex = '/(([0-9.?]+)([a-z%]+)?\s?)/ui';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setIsFont($isFont)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'YetiForcePDF\\Style\\Normalizer\\Normalizer';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getNumericUnit(string $value, string $defaultUnit): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setUnit($matches[1][3] ?? $originalUnit)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$unit = $matches[0][3];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool|string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $ruleValue
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected function threeValues(array $ruleNames, array $numberValues)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Normalize css rule.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$normalized[$ruleNames[3]] = $numberValues[1];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $ruleNames
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 1:
- Exclude checks