tobento/service-support

Interfaces and classes for supporting applications.

Maintainers

👁 TOBENTOch

Package info

github.com/tobento-ch/service-support

Homepage

pkg:composer/tobento/service-support

Statistics

Installs: 547

Dependents: 18

Suggesters: 0

Stars: 0

Open Issues: 0

2.0.3 2025-12-08 17:32 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 788039aa7e58535599672d4b76cd2609804b6935

packagetobento

This package is auto-updated.

Last update: 2026-06-08 18:38:04 UTC


README

The Support Service provides interfaces and classes supporting applications.

Table of Contents

Getting started

Add the latest version of the support service running this command.

composer require tobento/service-support

Requirements

  • PHP 8.4 or greater

Documentation

Interfaces

Arrayable

use Tobento\Service\Support\Arrayable;

interface Arrayable
{
 /**
 * Get the object as an array.
 *
 * @return array
 */
 public function toArray(): array; 
}

Htmlable

use Tobento\Service\Support\Htmlable;

interface Htmlable
{
 /**
 * Get content as a string of HTML.
 *
 * @return string
 */
 public function toHtml(): string;
}

Jsonable

use Tobento\Service\Support\Jsonable;

interface Jsonable
{
 /**
 * Get the object as a JSON string.
 *
 * @param int $options
 * @return string
 */
 public function toJson(int $options = 0): string; 
}

Renderable

use Tobento\Service\Support\Renderable;

interface Renderable
{
 /**
 * Get the evaluated contents of the object.
 *
 * @return string
 */
 public function render(): string; 
}

Responsable

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Tobento\Service\Support\Responsable;

interface Responsable
{
 /**
 * Create a HTTP response that represents the object.
 *
 * @param ServerRequestInterface $request
 * @return ResponseInterface
 */
 public function toResponse(ServerRequestInterface $request): ResponseInterface; 
}

Html String

The HtmlString::class can be useful in certain situations where a string should not be escaped by another function.

use Tobento\Service\Support\HtmlString;

$htmlString = new HtmlString('<h1>foo</h1>');

// you may check if the string is empty or not:
var_dump($htmlString->isEmpty());
// bool(false)

Credits