Changeset 52328 for trunk/src/wp-includes/Requests/Auth/Basic.php
- Timestamp:
- 12/06/2021 09:29:00 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/Requests/Auth/Basic.php
r52244 r52328 3 3 * Basic Authentication provider 4 4 * 5 * @package Requests\Authentication 5 * @package Requests 6 * @subpackage Authentication 6 7 */ 7 8 namespace WpOrg\Requests\Auth;9 10 use WpOrg\Requests\Auth;11 use WpOrg\Requests\Exception\ArgumentCount;12 use WpOrg\Requests\Exception\InvalidArgument;13 use WpOrg\Requests\Hooks;14 8 15 9 /** … … 19 13 * header. 20 14 * 21 * @package Requests\Authentication 15 * @package Requests 16 * @subpackage Authentication 22 17 */ 23 class Basic implementsAuth {18 class Requests_Auth_Basic implements Requests_Auth { 24 19 /** 25 20 * Username … … 39 34 * Constructor 40 35 * 41 * @since 2.0 Throws an `InvalidArgument` exception. 42 * @since 2.0 Throws an `ArgumentCount` exception instead of the Requests base `Exception. 43 * 36 * @throws Requests_Exception On incorrect number of arguments (`authbasicbadargs`) 44 37 * @param array|null $args Array of user and password. Must have exactly two elements 45 *46 * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed argument is not an array or null.47 * @throws \WpOrg\Requests\Exception\ArgumentCount On incorrect number of array elements (`authbasicbadargs`).48 38 */ 49 39 public function __construct($args = null) { 50 40 if (is_array($args)) { 51 41 if (count($args) !== 2) { 52 throw ArgumentCount::create('an array with exactly two elements', count($args), 'authbasicbadargs');42 throw new Requests_Exception('Invalid number of arguments', 'authbasicbadargs'); 53 43 } 54 44 55 45 list($this->user, $this->pass) = $args; 56 return;57 }58 59 if ($args !== null) {60 throw InvalidArgument::create(1, '$args', 'array|null', gettype($args));61 46 } 62 47 } … … 65 50 * Register the necessary callbacks 66 51 * 67 * @see \WpOrg\Requests\Auth\Basic::curl_before_send()68 * @see \WpOrg\Requests\Auth\Basic::fsockopen_header()69 * @param \WpOrg\Requests\Hooks $hooks Hook system52 * @see curl_before_send 53 * @see fsockopen_header 54 * @param Requests_Hooks $hooks Hook system 70 55 */ 71 public function register( Hooks $hooks) {72 $hooks->register('curl.before_send', [$this, 'curl_before_send']);73 $hooks->register('fsockopen.after_headers', [$this, 'fsockopen_header']);56 public function register(Requests_Hooks $hooks) { 57 $hooks->register('curl.before_send', array($this, 'curl_before_send')); 58 $hooks->register('fsockopen.after_headers', array($this, 'fsockopen_header')); 74 59 } 75 60 … … 77 62 * Set cURL parameters before the data is sent 78 63 * 79 * @param resource |\CurlHandle $handle cURL handle64 * @param resource $handle cURL resource 80 65 */ 81 66 public function curl_before_send(&$handle) {
Note: See TracChangeset
for help on using the changeset viewer.