Skip to content

Commit b6e8af9

Browse files
authored
Merge pull request #7 from MaplePHP/develop
Add path modifier
2 parents d6c7ec3 + 20a63de commit b6e8af9

File tree

7 files changed

+423
-493
lines changed

7 files changed

+423
-493
lines changed

.github/workflows/php.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: PHP Unitary
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
env:
17+
COMPOSER_ROOT_VERSION: 2.x-dev
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Cache Composer packages
23+
uses: actions/cache@v3
24+
with:
25+
path: vendor
26+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
27+
restore-keys: |
28+
${{ runner.os }}-php-
29+
30+
- name: Install dependencies
31+
run: composer install --prefer-dist --no-progress
32+
33+
- name: Run test suite
34+
run: php vendor/bin/unitary

composer.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
"homepage": "https://wazabii.se"
2828
}
2929
],
30+
"scripts": {
31+
"test": "php vendor/bin/unitary"
32+
},
3033
"require": {
3134
"php": ">=8.2",
3235
"psr/http-message": "^2.0",
@@ -44,11 +47,10 @@
4447
},
4548
"extra": {
4649
"branch-alias": {
47-
"dev-develop": "2.0.x-dev"
50+
"dev-main": "2.x-dev",
51+
"dev-develop": "2.x-dev"
4852
}
4953
},
5054
"minimum-stability": "dev",
51-
"scripts": {
52-
"unitary": "php vendor/bin/unitary"
53-
}
55+
"prefer-stable": true
5456
}

src/Interfaces/PathInterface.php

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
3+
namespace MaplePHP\Http\Interfaces;
4+
5+
6+
use Psr\Http\Message\UriInterface;
7+
8+
interface PathInterface
9+
{
10+
11+
/**
12+
* Get PSR URI instance with whitelisted path and
13+
* cleared, query and fragments
14+
*
15+
* @return UriInterface
16+
*/
17+
public function uri(): UriInterface;
18+
19+
/**
20+
* Get current full URL with whitelisted path
21+
*
22+
* @return string
23+
*/
24+
public function url(): string;
25+
26+
/**
27+
* With URI path type key
28+
*
29+
* @param null|string|array $type
30+
* @return static
31+
*/
32+
public function withType(null|string|array $type): self;
33+
34+
/**
35+
* Same as withType except that you Need to select a part
36+
*
37+
* @param string|array $type
38+
* @return static
39+
*/
40+
public function select(string|array $type): self;
41+
42+
/**
43+
* Same as withType except it will only reset
44+
*
45+
* @return static
46+
*/
47+
public function reset(): self;
48+
49+
/**
50+
* Append to URI path
51+
*
52+
* @param array|string $arr
53+
* @return static
54+
*/
55+
public function append(array|string $arr): self;
56+
57+
/**
58+
* Prepend to URI path
59+
*
60+
* @param array|string $arr
61+
* @return static
62+
*/
63+
public function prepend(array|string $arr): self;
64+
65+
/**
66+
* Get vars/path as array
67+
*
68+
* @return array
69+
*/
70+
public function vars(): array;
71+
72+
/**
73+
* Get vars/path as array
74+
*
75+
* @return array
76+
*/
77+
public function parts(): array;
78+
79+
/**
80+
* Get expected slug from path
81+
*
82+
* @return array
83+
*/
84+
public function get(): array;
85+
86+
/**
87+
* Get last path item
88+
*
89+
* @return string
90+
*/
91+
public function last(): string;
92+
93+
/**
94+
* Get first path item
95+
*
96+
* @return string
97+
*/
98+
public function first(): string;
99+
100+
/**
101+
* Get travers to prev path item
102+
*
103+
* @return string
104+
*/
105+
public function prev(): string;
106+
107+
/**
108+
* Get travers to next path item
109+
*
110+
* @return string
111+
*/
112+
public function next(): string;
113+
}

src/Interfaces/UrlInterface.php

Lines changed: 0 additions & 132 deletions
This file was deleted.

0 commit comments

Comments
 (0)