File Creator.php
has 664 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace SPHERE\Application\Api\Education\Certificate\Generator;
use MOC\V\Component\Document\Component\Bridge\Repository\DomPdf;
Function previewMultiPdf
has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring. Open
public static function previewMultiPdf($PrepareId = null, $GroupId = null, $Name = 'Zeugnis', $Redirect = true)
{
if ($Redirect) {
return self::displayWaitingPage('/Api/Education/Certificate/Generator/PreviewMultiPdf', array(
- 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
Function downloadMultiPdf
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
public static function downloadMultiPdf($PrepareId = null, $Name = 'Zeugnis', $Redirect = true)
{
if ($Redirect) {
return self::displayWaitingPage('/Api/Education/Certificate/Generator/DownLoadMultiPdf', array(
- 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
Function downloadMultiLeavePdf
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
public static function downloadMultiLeavePdf($DivisionId = null, $Name = 'Abgangszeugnis', $Redirect = true)
{
if ($Redirect) {
return self::displayWaitingPage('/Api/Education/Certificate/Generator/DownLoadMultiLeavePdf', array(
- 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
Function downloadZip
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
public function downloadZip($PrepareId = null, $Name = 'Zeugnis')
{
if (($tblPrepare = Prepare::useService()->getPrepareById($PrepareId))
&& ($tblDivision = $tblPrepare->getServiceTblDivision())
- 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
Function previewZip
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public function previewZip($PrepareId = null, $Name = 'Zeugnis Muster')
{
if (($tblPrepare = Prepare::useService()->getPrepareById($PrepareId))
&& ($tblDivision = $tblPrepare->getServiceTblDivision())
- 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
Function createPdf
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public function createPdf($PrepareId = null, $PersonId = null)
{
if (($tblPrepare = Prepare::useService()->getPrepareById($PrepareId))
&& ($tblPerson = Person::useService()->getPersonById($PersonId))
- 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
Function downloadHistoryZip
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function downloadHistoryZip($PrepareId = null, $Name = 'Zeugnis')
{
if (($tblPrepare = Prepare::useService()->getPrepareById($PrepareId))
&& ($tblDivision = $tblPrepare->getServiceTblDivision())
- 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
Method downloadMultiPdf
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function downloadMultiPdf($PrepareId = null, $Name = 'Zeugnis', $Redirect = true)
{
if ($Redirect) {
return self::displayWaitingPage('/Api/Education/Certificate/Generator/DownLoadMultiPdf', array(
Method previewMultiPdf
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function previewMultiPdf($PrepareId = null, $GroupId = null, $Name = 'Zeugnis', $Redirect = true)
{
if ($Redirect) {
return self::displayWaitingPage('/Api/Education/Certificate/Generator/PreviewMultiPdf', array(
Function previewPdf
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function previewPdf($PrepareId = null, $PersonId = null, $Name = 'Zeugnis Muster', $Redirect = true)
{
if ($Redirect) {
return self::displayWaitingPage('/Api/Education/Certificate/Generator/Preview', array(
- 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
Method downloadMultiLeavePdf
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function downloadMultiLeavePdf($DivisionId = null, $Name = 'Abgangszeugnis', $Redirect = true)
{
if ($Redirect) {
return self::displayWaitingPage('/Api/Education/Certificate/Generator/DownLoadMultiLeavePdf', array(
Method downloadZip
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function downloadZip($PrepareId = null, $Name = 'Zeugnis')
{
if (($tblPrepare = Prepare::useService()->getPrepareById($PrepareId))
&& ($tblDivision = $tblPrepare->getServiceTblDivision())
Function previewMultiLeavePdf
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public static function previewMultiLeavePdf($DivisionId = null, $Name = 'Abgangszeugnis', $Redirect = true)
{
if ($Redirect) {
return self::displayWaitingPage('/Api/Education/Certificate/Generator/PreviewMultiLeavePdf', array(
- 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
Method previewZip
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function previewZip($PrepareId = null, $Name = 'Zeugnis Muster')
{
if (($tblPrepare = Prepare::useService()->getPrepareById($PrepareId))
&& ($tblDivision = $tblPrepare->getServiceTblDivision())
Method downloadHistoryZip
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function downloadHistoryZip($PrepareId = null, $Name = 'Zeugnis')
{
if (($tblPrepare = Prepare::useService()->getPrepareById($PrepareId))
&& ($tblDivision = $tblPrepare->getServiceTblDivision())
Method previewMultiLeavePdf
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function previewMultiLeavePdf($DivisionId = null, $Name = 'Abgangszeugnis', $Redirect = true)
{
if ($Redirect) {
return self::displayWaitingPage('/Api/Education/Certificate/Generator/PreviewMultiLeavePdf', array(
Method previewPdf
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function previewPdf($PrepareId = null, $PersonId = null, $Name = 'Zeugnis Muster', $Redirect = true)
{
if ($Redirect) {
return self::displayWaitingPage('/Api/Education/Certificate/Generator/Preview', array(
Method createPdf
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createPdf($PrepareId = null, $PersonId = null)
{
if (($tblPrepare = Prepare::useService()->getPrepareById($PrepareId))
&& ($tblPerson = Person::useService()->getPersonById($PersonId))
Function previewLeavePdf
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function previewLeavePdf($LeaveStudentId = null, $Name = 'Zeugnis Muster', $Redirect = true)
{
if ($Redirect) {
return self::displayWaitingPage('/Api/Education/Certificate/Generator/PreviewLeave', array(
- 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
Method previewLeavePdf
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function previewLeavePdf($LeaveStudentId = null, $Name = 'Zeugnis Muster', $Redirect = true)
{
if ($Redirect) {
return self::displayWaitingPage('/Api/Education/Certificate/Generator/PreviewLeave', array(
Avoid deeply nested control flow statements. Open
if (isset($Content['P' . $personId]['Grade'])) {
$Certificate->setGrade($Content['P' . $personId]['Grade']);
}
Avoid deeply nested control flow statements. Open
if (isset($Content['P' . $personId]['AdditionalGrade'])) {
$Certificate->setAdditionalGrade($Content['P' . $personId]['AdditionalGrade']);
}
Avoid deeply nested control flow statements. Open
if (isset($Data['P' . $personId]['Grade'])) {
$Certificate->setGrade($Data['P' . $personId]['Grade']);
}
Avoid deeply nested control flow statements. Open
if (isset($Content['P' . $personId]['Grade'])) {
$Certificate->setGrade($Content['P' . $personId]['Grade']);
}
Avoid deeply nested control flow statements. Open
if (class_exists($CertificateClass)) {
/** @var \SPHERE\Application\Api\Education\Certificate\Generator\Certificate $Certificate */
$Certificate = new $CertificateClass($tblDivision, null, false);
Avoid deeply nested control flow statements. Open
if (isset($Content['P' . $personId]['AdditionalGrade'])) {
$Certificate->setAdditionalGrade($Content['P' . $personId]['AdditionalGrade']);
}
Avoid deeply nested control flow statements. Open
if (class_exists($CertificateClass)) {
/** @var \SPHERE\Application\Api\Education\Certificate\Generator\Certificate $Certificate */
$Certificate = new $CertificateClass($tblDivision, $tblPrepare);
Avoid deeply nested control flow statements. Open
if (($tblDivision = $tblPrepare->getServiceTblDivision()) && !$tblPrepareStudent->isPrinted()) {
if (Storage::useService()->saveCertificateRevision($tblPerson, $tblDivision, $Certificate,
$File, $tblPrepare)
) {
Prepare::useService()->updatePrepareStudentSetPrinted($tblPrepareStudent);
Avoid deeply nested control flow statements. Open
if (isset($Content['P' . $personId]['AdditionalGrade'])) {
$Certificate->setAdditionalGrade($Content['P' . $personId]['AdditionalGrade']);
}
Avoid deeply nested control flow statements. Open
if (isset($Content['P' . $personId]['Grade'])) {
$Certificate->setGrade($Content['P' . $personId]['Grade']);
}
Avoid deeply nested control flow statements. Open
if (isset($Content['P' . $personId]['AdditionalGrade'])) {
$Certificate->setAdditionalGrade($Content['P' . $personId]['AdditionalGrade']);
}
Avoid deeply nested control flow statements. Open
if (($tblDivision = $tblPrepare->getServiceTblDivision()) && !$tblPrepareStudent->isPrinted()) {
if (Storage::useService()->saveCertificateRevision($tblPerson, $tblDivision,
$Certificate,
$File, $tblPrepare)
) {
Avoid deeply nested control flow statements. Open
if (($tblDivision = $tblPrepare->getServiceTblDivision()) && !$tblPrepareStudent->isPrinted()) {
if (Storage::useService()->saveCertificateRevision($tblPerson, $tblDivision,
$Certificate,
$File, $tblPrepare)
) {
Avoid deeply nested control flow statements. Open
if (isset($Data['P' . $personId]['AdditionalGrade'])) {
$Certificate->setAdditionalGrade($Data['P' . $personId]['AdditionalGrade']);
}
Avoid deeply nested control flow statements. Open
if (isset($Content['P' . $personId]['Grade'])) {
$Certificate->setGrade($Content['P' . $personId]['Grade']);
}
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (!empty($FileList)) {
$ZipFile = new FilePointer('zip');
$ZipFile->saveFile();
$ZipArchive = $this->getPacker($ZipFile->getRealPath());
- 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 152.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (!empty($FileList)) {
$ZipFile = new FilePointer('zip');
$ZipFile->saveFile();
$ZipArchive = $this->getPacker($ZipFile->getRealPath());
- 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 152.
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