Skip to content

Commit 1d7effc

Browse files
committed
Adds configurable mutability options
1 parent 19aca0d commit 1d7effc

File tree

5 files changed

+92
-18
lines changed

5 files changed

+92
-18
lines changed

src/Configurable.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
/**
1515
* Allows global configurations
1616
*
17+
* This interface does not allow modifying options
18+
* Check the specific mutable and immutable interfaces
19+
*
1720
* @author Márk Sági-Kazár [email protected]>
1821
*/
1922
interface Configurable
2023
{
2124
/**
22-
* Returns a sepcific option or null
25+
* Returns an option by name
2326
*
2427
* @param string $name
2528
*
@@ -35,7 +38,7 @@ public function getOption($name);
3538
public function getOptions();
3639

3740
/**
38-
* Checks if an option is set
41+
* Checks if an option exists
3942
*
4043
* @param string $name
4144
*
@@ -44,17 +47,9 @@ public function getOptions();
4447
public function hasOption($name);
4548

4649
/**
47-
* Sets an option
50+
* Checks if any option exists
4851
*
49-
* @param string $name
50-
* @param mixed $option
51-
*/
52-
public function setOption($name, $option);
53-
54-
/**
55-
* Sets all options
56-
*
57-
* @param array $options
52+
* @return boolean
5853
*/
59-
public function setOptions($options);
54+
public function hasOptions();
6055
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Http Adapter package.
5+
*
6+
* (c) Eric GELOEN <[email protected]>
7+
*
8+
* For the full copyright and license information, please read the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Http\Adapter\Configurable;
13+
14+
use Http\Adapter\Configurable;
15+
16+
/**
17+
* Allows to modify configuration an immutable way
18+
*
19+
* @author Márk Sági-Kazár [email protected]>
20+
*/
21+
interface ImmutableConfigurable extends Configurable
22+
{
23+
/**
24+
* Sets an option
25+
*
26+
* @param string $name
27+
* @param mixed $option
28+
*
29+
* @return self
30+
*/
31+
public function withOption($name, $option);
32+
33+
/**
34+
* Removes an option
35+
*
36+
* @param string $name
37+
*
38+
* @return self
39+
*/
40+
public function withoutOption($name);
41+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Http Adapter package.
5+
*
6+
* (c) Eric GELOEN <[email protected]>
7+
*
8+
* For the full copyright and license information, please read the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Http\Adapter\Configurable;
13+
14+
use Http\Adapter\Configurable;
15+
16+
/**
17+
* Allows to modify configuration a mutable way
18+
*
19+
* @author Márk Sági-Kazár [email protected]>
20+
*/
21+
interface MutableConfigurable extends Configurable
22+
{
23+
/**
24+
* Sets an option
25+
*
26+
* @param string $name
27+
* @param mixed $option
28+
*/
29+
public function setOption($name, $option);
30+
31+
/**
32+
* Sets all options
33+
*
34+
* @param array $options
35+
*/
36+
public function setOptions($options);
37+
}

src/Message/InternalRequest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111

1212
namespace Http\Adapter\Message;
1313

14+
use Http\Adapter\Configurable\ImmutableConfigurable;
1415
use Psr\Http\Message\RequestInterface;
1516

1617
/**
1718
* @author GeLo <[email protected]>
1819
*/
19-
interface InternalRequest extends RequestInterface, ParameterableMessage
20+
interface InternalRequest extends RequestInterface, ParameterableMessage, ImmutableConfigurable
2021
{
2122
/**
2223
* Returns some data by name
@@ -89,14 +90,14 @@ public function withoutData($name);
8990
public function getFile($name);
9091

9192
/**
92-
* Returns the files
93+
* Returns all files
9394
*
9495
* @return array
9596
*/
9697
public function getFiles();
9798

9899
/**
99-
* Checks if the file exists
100+
* Checks if a file exists
100101
*
101102
* @param string $name
102103
*

src/Message/ParameterableMessage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ interface ParameterableMessage
2828
public function getParameter($name);
2929

3030
/**
31-
* Returns the parameters
31+
* Returns all parameters
3232
*
3333
* @return array
3434
*/
3535
public function getParameters();
3636

3737
/**
38-
* Checks if the parameter exists
38+
* Checks if a parameter exists
3939
*
4040
* @param string $name
4141
*

0 commit comments

Comments
 (0)