File: scheme.md

package info (click to toggle)
php-league-uri-src 7.5.1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,712 kB
  • sloc: php: 16,698; javascript: 127; makefile: 43; xml: 36
file content (54 lines) | stat: -rw-r--r-- 1,716 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
layout: default
title: The Scheme component
redirect_from:
    - /5.0/components/scheme/
---

# The Scheme component

The library provides a `Scheme` class to ease scheme creation and manipulation.

## Creating a new object

~~~php
<?php
public Scheme::__construct(?string $content = null): void
~~~

<p class="message-warning">If the submitted value is not valid a <code>League\Uri\Components\Exception</code> exception is thrown.</p>

The `League\Uri\Components\Exception` extends PHP's SPL `InvalidArgumentException`.

## Properties and methods

This URI component object only exposes the [package common API](/components/1.0/api/).

## Usage

~~~php
<?php

use League\Uri\Components\Scheme;

$scheme = new Scheme('FtP');
$scheme->isNull();  //return false
$scheme->isEmpty(); //return false
echo $scheme->getContent();                         //display 'ftp'
echo $scheme->getContent(Scheme::RFC3986_ENCODING); //display 'ftp'
echo $scheme->getContent(Scheme::RFC3987_ENCODING); //display 'ftp'
echo $scheme->getContent(Scheme::NO_ENCODING);      //display 'ftp'
echo $scheme;                    //display 'ftp'
echo $scheme->getUriComponent(); //display 'ftp:'

$new_scheme = $scheme->withContent(null);
$new_scheme->isNull();  //return true
$new_scheme->isEmpty(); //return true
echo $new_scheme->getContent();      //display null
echo $new_scheme;                    //display ''
echo $new_scheme->getUriComponent(); //display ''
~~~

<p class="message-notice">The delimiter <code>:</code> is not part of the component value and <strong>must not</strong> be added.</p>

<p class="message-warning">If the submitted value is not valid a <code>League\Uri\Components\Exception</code> exception is thrown.</p>