| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace WordPress\AiClientDependencies\Http\Discovery\Exception; 4 5 use WordPress\AiClientDependencies\Http\Discovery\Exception; 6 /** 7 * When we have used a strategy but no candidates provided by that strategy could be used. 8 * 9 * @author Tobias Nyholm <tobias.nyholm@gmail.com> 10 */ 11 final class NoCandidateFoundException extends \Exception implements Exception 12 { 13 /** 14 * @param string $strategy 15 */ 16 public function __construct($strategy, array $candidates) 17 { 18 $classes = array_map(function ($a) { 19 return $a['class']; 20 }, $candidates); 21 $message = sprintf('No valid candidate found using strategy "%s". We tested the following candidates: %s.', $strategy, implode(', ', array_map([$this, 'stringify'], $classes))); 22 parent::__construct($message); 23 } 24 private function stringify($mixed) 25 { 26 if (is_string($mixed)) { 27 return $mixed; 28 } 29 if (is_array($mixed) && 2 === count($mixed)) { 30 return sprintf('%s::%s', $this->stringify($mixed[0]), $mixed[1]); 31 } 32 return is_object($mixed) ? get_class($mixed) : gettype($mixed); 33 } 34 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sat Jun 13 09:38:55 2026 | Cross-referenced by PHPXref |