Skip to content

Commit

Permalink
Plugin/Method/ReqRes: update bdk\HttpMessage\Utility\HttpFoundationBr…
Browse files Browse the repository at this point in the history
…idge namespace

Add two methods to our autoloader:  `addClass()` and `addPsr4()`
  • Loading branch information
bkdotcom committed Jul 12, 2024
1 parent 3e0be17 commit 5234f1f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/CurlHttpMessage/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function buildRequest($method, $uri, $headers = array(), $body = null)
*/
public function buildResponse($code = 200, $reasonPhrase = '', $headers = array(), $body = null)
{
$response = new Response($code, $reasonPhrase);
$response = new Response($code, (string) $reasonPhrase);
$response = $this->withHeaders($response, $headers);
$response = $this->withBody($response, $body);
return $response;
Expand Down
28 changes: 28 additions & 0 deletions src/Debug/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,34 @@ public function unregister()
return \spl_autoload_unregister(array($this, 'autoload'));
}

/**
* Add classname to classMap
*
* @param string $className ClassName
* @param string $filepath Filepath to class' definition
*
* @return static
*/
public function addClass($className, $filepath)
{
$this->classMap[$className] = $filepath;
return $this;
}

/**
* Add Psr4 mapping to autoloader
*
* @param string $namespace Namespace prefix
* @param string $dir Directory containing namespace
*
* @return static
*/
public function addPsr4($namespace, $dir)
{
$this->psr4Map[$namespace] = $dir;
return $this;
}

/**
* Debug class autoloader
*
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Plugin/Method/ReqRes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use bdk\Debug;
use bdk\Debug\Plugin\CustomMethodTrait;
use bdk\HttpMessage\HttpFoundationBridge;
use bdk\HttpMessage\Utility\HttpFoundationBridge;
use bdk\HttpMessage\Utility\Response as ResponseUtil;
use bdk\PubSub\Event;
use bdk\PubSub\SubscriberInterface;
Expand Down
6 changes: 0 additions & 6 deletions tests/CurlHttpMessage/Middleware/FollowLocationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

namespace bdk\Test\CurlHttpMessage\Middleware;

/*
use bdk\CurlHttpMessage\Handler\CurlMulti;
use bdk\HttpMessage\Request;
*/

use bdk\CurlHttpMessage\Client;
use bdk\CurlHttpMessage\CurlReqRes;
use bdk\CurlHttpMessage\Exception\RequestException;
use bdk\CurlHttpMessage\Handler\Mock as MockHandler;
use bdk\CurlHttpMessage\Middleware\FollowLocation;
Expand Down
2 changes: 2 additions & 0 deletions tests/Debug/noComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
require __DIR__ . '/../../src/Debug/Autoloader.php';
$autoloader = new \bdk\Debug\Autoloader();
$autoloader->register();
$autoloader->addPsr4('bdk\\HttpMessage\\', __DIR__ . '/../../vendor/bdk/http-message/src/HttpMessage');
$autoloader->addPsr4('Psr\\Http\\Message\\', __DIR__ . '/../../vendor/psr/http-message/src');

$debug = new \bdk\Debug(array(
'collect' => true,
Expand Down

0 comments on commit 5234f1f

Please sign in to comment.