| Conditions | 8 |
| Paths | 2 |
| Total Lines | 32 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 72 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | public function defaultSliderSettings() |
||
| 34 | { |
||
| 35 | $ct = 0; |
||
| 36 | |||
| 37 | $objects = ClassInfo::subclassesFor('DataObject'); |
||
| 38 | if ($objects) { |
||
|
|
|||
| 39 | unset($objects['DataObject']); |
||
| 40 | foreach ($objects as $object) { |
||
| 41 | if (singleton($object)->hasExtension('FlexSlider')) { |
||
| 42 | foreach ($object::get() as $result) { |
||
| 43 | $result->Loop = 1; |
||
| 44 | $result->Animate = 1; |
||
| 45 | $result->SliderControlNav = 1; |
||
| 46 | $result->SliderDirectionNav = 1; |
||
| 47 | $result->CarouselControlNav = 0; |
||
| 48 | $result->CarouselDirectionNav = 1; |
||
| 49 | $result->CarouselThumbnailCt = 6; |
||
| 50 | if ($result InstanceOf SiteTree || singleton($object)->hasExtension('VersionedDataobject')) { |
||
| 51 | $result->writeToStage('Stage'); |
||
| 52 | if ($result->isPublished()) { |
||
| 53 | $result->publish('Stage', 'Live'); |
||
| 54 | } |
||
| 55 | } else { |
||
| 56 | $result->write(); |
||
| 57 | } |
||
| 58 | $ct++; |
||
| 59 | } |
||
| 60 | } |
||
| 61 | } |
||
| 62 | } |
||
| 63 | echo '<p>'.$ct.' Sliders updated.</p>'; |
||
| 64 | } |
||
| 65 | } |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.