| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace SteamMarketProviders\ParserManager\Parser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use PHPHtmlParser\Exceptions\ChildNotFoundException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use PHPHtmlParser\Exceptions\CircularException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use PHPHtmlParser\Exceptions\ContentLengthException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use PHPHtmlParser\Exceptions\LogicalException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use PHPHtmlParser\Exceptions\NotLoadedException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use PHPHtmlParser\Exceptions\StrictException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use SteamMarketProviders\ParserManager\Builder\ParseRulesBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use SteamMarketProviders\ParserManager\Contract\UrlBuilderInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use SteamMarketProviders\ParserManager\Exception\HttpException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use SteamMarketProviders\ParserManager\Parser\Provider\AbstractProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use SteamMarketProviders\ParserManager\Contract\StrategyInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | final class SteamParser | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * @param AbstractProvider $abstractProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     public function __construct(private AbstractProvider $abstractProvider) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * @param StrategyInterface $strategy | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     public function setHttpStrategy(StrategyInterface $strategy): SteamParser | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         $this->abstractProvider->setHttpStrategy($strategy); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * @param ParseRulesBuilder $parseRulesBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     public function setParseRules(ParseRulesBuilder $parseRulesBuilder): SteamParser | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $this->abstractProvider->setParseRules($parseRulesBuilder); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 46 |  |  |         return $this; | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |     public function setUrl(UrlBuilderInterface $urlBuilder): SteamParser | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $this->abstractProvider->setUrl($urlBuilder); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * @param int $page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @throws ChildNotFoundException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * @throws CircularException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * @throws ContentLengthException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * @throws LogicalException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * @throws NotLoadedException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * @throws StrictException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @throws HttpException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     public function run(int $page = 1): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         return $this->abstractProvider->start($page); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 71 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 72 |  |  |  |