src/Builder.php
public function checkbox(
        string $id,
        string $title,
        array $additionalArguments = null
    ): Field {
        $formControl = $this->builder->checkbox($id)->value('true');
        $this->optionStore->getBoolean($id) ? $formControl->check() : $formControl->uncheck();

        $additionalArguments = array_merge(
            [
                'type' => 'boolean',
                'sanitize_callback' => function ($value): bool {
                    return 'true' === sanitize_text_field($value);
                },
            ],
            (array) $additionalArguments
        );

        return new Field(
            $id,
            $title,
            $formControl,
            (array) $additionalArguments
        );
    }
public function checkbox(
        string $id,
        string $title,
        array $additionalArguments = null
    ): Field {
        $formControl = $this->builder->checkbox($id)->value('true');
        $this->optionStore->getBoolean($id) ? $formControl->check() : $formControl->uncheck();

        $additionalArguments = array_merge(
            [
                'type' => 'boolean',
                'sanitize_callback' => function ($value): bool {
                    return 'true' === sanitize_text_field($value);
                },
            ],
            (array) $additionalArguments
        );

        return new Field(
            $id,
            $title,
            $formControl,
            (array) $additionalArguments
        );
    }
Build a checkbox field.

@param string $id                  String for use in the 'id' attribute of tags.
@param string $title               Title of the field.
@param array  $additionalArguments Optional. Additional arguments that are passed to `register_setting` and
`add_settings_field`.

@return Field