![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/captainhook/secrets/src/ |
<?php /** * This file is part of secrets. * * (c) Sebastian Feldmann <[email protected]> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace CaptainHook\Secrets; use CaptainHook\Secrets\Regex\Grouped; class Regexer { /** * @var \CaptainHook\Secrets\Regex\Grouped */ private Grouped $supplier; /** * Creates a new Detector * * @return \CaptainHook\Secrets\Regexer */ public static function create(): self { return new self(); } /** * The Regexer can only deal with Grouped Suppliers * Those Suppliers provide the index of the detection group where to find the potential password. * * @param \CaptainHook\Secrets\Regex\Grouped $supplier * @return $this */ public function useGroupedSupplier(Grouped $supplier): self { $this->supplier = $supplier; return $this; } /** * Returns a lost of all potential passwords * * @param string $text * @return \CaptainHook\Secrets\Result */ public function detectIn(string $text): Result { $allMatches = []; foreach ($this->supplier->patterns() as $num => $regex) { $matches = []; if (preg_match($regex, $text, $matches)) { $allMatches[] = $matches[$this->supplier->indexes()[$num]]; } } return new Result($allMatches); } }