PHP code example of bypassflow / standards

1. Go to this page and download the library: Download bypassflow/standards library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bypassflow / standards example snippets




declare(strict_types=1);

use bypassflow\Standards\PhpCsFixer\CustomFixer\LeadingContinuationIndentFixer;
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

return (new Config())->setFinder((new Finder())->in([
    \sprintf('%s/src', __DIR__),
    \sprintf('%s/tests', __DIR__),
]))->registerCustomFixers([
    new LeadingContinuationIndentFixer(),
])->setRules([
    'Bypassflow/leading_continuation_indent' => true,
]);



declare(strict_types=1);

function resolve_label(?string $display_name, string $fallback_name, bool $is_enabled): string
{
    $name = $display_name
     ?? $fallback_name;

    return $is_enabled
     ? $name
     : 'disabled';
}



declare(strict_types=1);

function resolve_schedule_label(\DateTimeImmutable $baseAt, bool $prefer_jst): string
{
    if ($prefer_jst && $baseAt
    ->setTimezone(new \DateTimeZone('Asia/Tokyo'))
    ->format('N') !== '7') {
        return $baseAt
        ->setTimezone(new \DateTimeZone('Asia/Tokyo'))
        ->setTime(9, 0)
        ->format(\DateTimeInterface::ATOM);
    }

    return $baseAt
    ->setTimezone(new \DateTimeZone('UTC'))
    ->setTime(0, 0)
    ->format(\DateTimeInterface::ATOM);
}
bash
php tools/php/check-line-break-style.php src tests