src/Page/ProductPage.php
File ProductPage.php
has 337 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
namespace Dynamic\FoxyStripe\Page;
use Bummzack\SortableFile\Forms\SortableUploadField;
- Create a ticketCreate a ticket
Method getCMSFields
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function getCMSFields()
{
$this->beforeUpdateCMSFields(function (FieldList $fields) {
// Cateogry Dropdown field w/ add new
$source = function () {
- Create a ticketCreate a ticket
Function onBeforeWrite
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
public function onBeforeWrite()
{
parent::onBeforeWrite();
if (!$this->CategoryID) {
$default = ProductCategory::get()->filter(['Code' => 'DEFAULT'])->first();
- Read upRead up
- Create a ticketCreate a ticket
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 getGeneratedValue
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
$productCode = null,
$optionName = null,
$optionValue = null,
$method = 'name',
$output = false,
- Create a ticketCreate a ticket
Function onBeforeDelete
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
public function onBeforeDelete()
{
if ($this->Status != 'Published') {
if ($this->ProductOptions()) {
$options = $this->getComponents('ProductOptions');
- Read upRead up
- Create a ticketCreate a ticket
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"