1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
use Chemaclass\StockTicker\Domain\Crawler\Site\Barrons\BarronsSiteCrawler; |
6
|
|
|
use Chemaclass\StockTicker\Domain\Crawler\Site\Barrons\HtmlCrawler; |
7
|
|
|
use Chemaclass\StockTicker\Domain\Crawler\Site\FinanceYahoo\FinanceYahooSiteCrawler; |
8
|
|
|
use Chemaclass\StockTicker\Domain\Crawler\Site\FinanceYahoo\JsonExtractor; |
9
|
|
|
use Chemaclass\StockTicker\Domain\Crawler\Site\Shared\NewsNormalizer; |
10
|
|
|
use Chemaclass\StockTicker\Domain\Notifier\Channel\Email\EmailChannel; |
11
|
|
|
use Chemaclass\StockTicker\Domain\Notifier\Channel\Slack\HttpSlackClient; |
12
|
|
|
use Chemaclass\StockTicker\Domain\Notifier\Channel\Slack\SlackChannel; |
13
|
|
|
use Chemaclass\StockTicker\Domain\Notifier\Channel\TwigTemplateGenerator; |
14
|
|
|
use Symfony\Component\HttpClient\HttpClient; |
15
|
|
|
use Symfony\Component\Mailer\Bridge\Google\Transport\GmailSmtpTransport; |
16
|
|
|
use Symfony\Component\Mailer\Mailer; |
17
|
|
|
use Twig\Environment; |
18
|
|
|
use Twig\Loader\FilesystemLoader; |
19
|
|
|
|
20
|
|
|
require_once dirname(__DIR__) . '/vendor/autoload.php'; |
21
|
|
|
|
22
|
|
|
Dotenv\Dotenv::createImmutable(__DIR__)->load(); |
23
|
|
|
|
24
|
|
|
/* |
25
|
|
|
* ====================================================== |
26
|
|
|
* This `autoload.php` and these functions are just for |
27
|
|
|
* the example usage. |
28
|
|
|
* ====================================================== |
29
|
|
|
*/ |
30
|
|
|
|
31
|
|
|
function createFinanceYahooSiteCrawler(int $maxNewsToFetch = 2): FinanceYahooSiteCrawler |
32
|
|
|
{ |
33
|
|
|
return new FinanceYahooSiteCrawler([ |
34
|
|
|
'NAME' => new JsonExtractor\QuoteSummaryStore\CompanyName(), |
35
|
|
|
'PRICE' => new JsonExtractor\QuoteSummaryStore\RegularMarketPrice(), |
36
|
|
|
'CURRENCY' => new JsonExtractor\QuoteSummaryStore\Currency(), |
37
|
|
|
'CHANGE' => new JsonExtractor\QuoteSummaryStore\RegularMarketChange(), |
38
|
|
|
'CHANGE_PERCENT' => new JsonExtractor\QuoteSummaryStore\RegularMarketChangePercent(), |
39
|
|
|
'TREND' => new JsonExtractor\QuoteSummaryStore\RecommendationTrend(), |
40
|
|
|
'NEWS' => new JsonExtractor\StreamStore\News(new NewsNormalizer(new DateTimeZone('Europe/Berlin'), $maxNewsToFetch)), |
|
|
|
|
41
|
|
|
'URL' => new JsonExtractor\RouteStore\ExternalUrl(), |
42
|
|
|
]); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
function createBarronsSiteCrawler(int $maxNewsToFetch = 2): BarronsSiteCrawler |
46
|
|
|
{ |
47
|
|
|
return new BarronsSiteCrawler([ |
48
|
|
|
'NEWS' => new HtmlCrawler\News(new NewsNormalizer(new DateTimeZone('Europe/Berlin'), $maxNewsToFetch)), |
49
|
|
|
]); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
function createEmailChannel(string $templateName = 'email.twig'): EmailChannel |
53
|
|
|
{ |
54
|
|
|
return new EmailChannel( |
55
|
|
|
$_ENV['TO_ADDRESS'], |
56
|
|
|
new Mailer(new GmailSmtpTransport( |
57
|
|
|
$_ENV['MAILER_USERNAME'], |
58
|
|
|
$_ENV['MAILER_PASSWORD'] |
59
|
|
|
)), |
60
|
|
|
new TwigTemplateGenerator( |
61
|
|
|
new Environment(new FilesystemLoader(__DIR__ . '/templates')), |
62
|
|
|
$templateName |
63
|
|
|
) |
64
|
|
|
); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
function createSlackChannel(string $templateName = 'slack.twig'): SlackChannel |
68
|
|
|
{ |
69
|
|
|
return new SlackChannel( |
70
|
|
|
$_ENV['SLACK_DESTINY_CHANNEL_ID'], |
71
|
|
|
new HttpSlackClient(HttpClient::create([ |
72
|
|
|
'auth_bearer' => $_ENV['SLACK_BOT_USER_OAUTH_ACCESS_TOKEN'], |
73
|
|
|
])), |
74
|
|
|
new TwigTemplateGenerator( |
75
|
|
|
new Environment(new FilesystemLoader(__DIR__ . '/templates')), |
76
|
|
|
$templateName |
77
|
|
|
) |
78
|
|
|
); |
79
|
|
|
} |
80
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths