Skip to content

Commit e95d87b

Browse files
authored
Use ternary operator for libraries code (joomla#44921)
1 parent d608b7d commit e95d87b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

libraries/src/Form/Field/CalendarField.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,16 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
233233
$return = parent::setup($element, $value, $group);
234234

235235
if ($return) {
236-
$this->maxlength = (int) $this->element['maxlength'] ? (int) $this->element['maxlength'] : 45;
237-
$this->format = (string) $this->element['format'] ? (string) $this->element['format'] : '%Y-%m-%d';
238-
$this->filterFormat = (string) $this->element['filterformat'] ? (string) $this->element['filterformat'] : '';
239-
$this->filter = (string) $this->element['filter'] ? (string) $this->element['filter'] : 'USER_UTC';
240-
$this->todaybutton = (string) $this->element['todaybutton'] ? (string) $this->element['todaybutton'] : 'true';
241-
$this->weeknumbers = (string) $this->element['weeknumbers'] ? (string) $this->element['weeknumbers'] : 'true';
242-
$this->showtime = (string) $this->element['showtime'] ? (string) $this->element['showtime'] : 'false';
243-
$this->filltable = (string) $this->element['filltable'] ? (string) $this->element['filltable'] : 'true';
244-
$this->timeformat = (int) $this->element['timeformat'] ? (int) $this->element['timeformat'] : 24;
245-
$this->singleheader = (string) $this->element['singleheader'] ? (string) $this->element['singleheader'] : 'false';
236+
$this->maxlength = (int) $this->element['maxlength'] ?: 45;
237+
$this->format = (string) $this->element['format'] ?: '%Y-%m-%d';
238+
$this->filterFormat = (string) $this->element['filterformat'] ?: '';
239+
$this->filter = (string) $this->element['filter'] ?: 'USER_UTC';
240+
$this->todaybutton = (string) $this->element['todaybutton'] ?: 'true';
241+
$this->weeknumbers = (string) $this->element['weeknumbers'] ?: 'true';
242+
$this->showtime = (string) $this->element['showtime'] ?: 'false';
243+
$this->filltable = (string) $this->element['filltable'] ?: 'true';
244+
$this->timeformat = (int) $this->element['timeformat'] ?: 24;
245+
$this->singleheader = (string) $this->element['singleheader'] ?: 'false';
246246
$this->minyear = \strlen((string) $this->element['minyear']) ? (int) $this->element['minyear'] : null;
247247
$this->maxyear = \strlen((string) $this->element['maxyear']) ? (int) $this->element['maxyear'] : null;
248248

libraries/src/Form/Form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ protected function loadField($element, $group = null, $value = null)
14871487
* else the value of the 'default' attribute for the field.
14881488
*/
14891489
if ($value === null) {
1490-
$default = (string) ($element['default'] ? $element['default'] : $element->default);
1490+
$default = (string) ($element['default'] ?: $element->default);
14911491

14921492
if (($translate = $element['translate_default']) && ((string) $translate === 'true' || (string) $translate === '1')) {
14931493
$lang = Factory::getLanguage();

0 commit comments

Comments
 (0)