public function testActuallyEmptyEmptyArray() { // arrange $value = []; // act $empty = actually_empty($value); // assert $this->assertFalse($empty); }
function markup_field($string, $title, $raw = false) { $markup = ''; $markup .= '<div class="static-field"><strong>' . npmmo_esc($title) . '</strong><p>'; if (actually_empty($string)) { $markup .= '<span class="muted">blank</span>'; } else { if ($raw) { $markup .= $string; } else { $markup .= npmmo_esc($string); } } $markup .= '</p></div>'; return $markup; }
@endif </td> @include('layouts.email._expander') </tr> </table> </td> </tr> </table> @if ( isset($instructions) && !actually_empty($instructions) ) <?php $processed_instructions = array_filter($instructions, function ($element) { return !actually_empty($element['body']); }); $i = 1; ?> @foreach($processed_instructions as $instruction) <?php // ALL for the last element to add a border-bottom if ($i == count($processed_instructions)) { $last = true; } else { $last = false; } $i += 1;
function npmso_build_email_contact_info_sentence($participants, $sponsorships, $name, $email, $phone) { // 'Your slot(s) are reserved, but if you have location-specific questions or need more information before the event, you may contact Doc Brown at doc@einsteinlabs.com or (916) 555-4385.' // Remove the plank from your own eye before you read this function. $sentence = ['Your ']; // Build the beginning of the sentence if sponsorships are present // Should build either: // "Your 'n' sponsorship(s) are reserved for your 'n' participants, " // or if no participants // "Your 'n' sponsorship(s) are reserved, " if (!actually_empty($sponsorships)) { $fragment = pluralize($sponsorships, 'sponsorship'); $fragment .= $sponsorships == 1 ? ' is' : ' are'; $fragment .= ' reserved'; array_push($sentence, $fragment); if (!actually_empty($participants)) { $fragment = ' for your ' . pluralize($participants, 'volunteer'); array_push($sentence, $fragment); } } // Build the beginning of the sentence if only participants are present. No sponsorship. // Should build // "Your 'n' slots are reserved, " if (!actually_empty($participants) && actually_empty($sponsorships)) { $fragment = pluralize($participants, 'slot'); $fragment .= $participants == 1 ? ' is' : ' are'; $fragment .= ' reserved'; array_push($sentence, $fragment); } if (!actually_empty($name) || !actually_empty($email) || !actually_empty($phone)) { // // Add non-dynamic portion of the sentence. $fragment = ', but if you have location-specific questions or need more information before the event, you may contact '; array_push($sentence, $fragment); // Adds "name at " if (!actually_empty($name)) { $fragment = $name; array_push($sentence, $fragment); if (!actually_empty($email) || !actually_empty($phone)) { array_push($sentence, ' at '); } else { array_push($sentence, '.'); } } // Adds email and possibly phone. if (!actually_empty($email)) { $fragment = $email; array_push($sentence, $fragment); if (!actually_empty($phone)) { $fragment = ' or ' . $phone . '.'; array_push($sentence, $fragment); } else { array_push($sentence, '.'); } } // Adds phone if it wasn't added with the email. if (!actually_empty($phone) && actually_empty($email)) { $fragment = $phone . '.'; array_push($sentence, $fragment); } } else { array_push($sentence, '.'); } return join($sentence); }