<?php

  namespace Ngam;

  require_once __DIR__ . '/vendor/autoload.php';

  use \Laodc\Container\Container;
  use \Laodc\Router\Router;
  use \Laodc\Template\Template;
  use \Laodc\Database\Database;
  use \Laodc\Config\{Config,Tags};

  const BASE_DIR = __DIR__;

  $conf = new Config();
  $conf->path( __DIR__ . '/.c/' );

  /*
  $mail_config = $conf->load( 'mail.yml' );

  $mailbox_path = sprintf( "{%s:%d%s}%s", $mail_config->host, $mail_config->port, $mail_config->mode, $mail_config->folder );

  // Create PhpImap\Mailbox instance for all further actions
  $mailbox = new \PhpImap\Mailbox(
    $mailbox_path, // IMAP server and mailbox folder
    $mail_config->email, // Username for the before configured mailbox
    $mail_config->password, // Password for the before configured username
    __DIR__, // Directory, where attachments will be saved (optional)
    'UTF-8', // Server encoding (optional)
    true, // Trim leading/ending whitespaces of IMAP path (optional)
    false // Attachment filename mode (optional; false = random filename; true = original filename)
  );

  try
  {
    // Get all emails (messages)
    // PHP.net imap_search criteria: http://php.net/manual/en/function.imap-search.php
    $mailsIds = $mailbox->searchMailbox( 'ALL' );

    var_dump( $mailsIds );

    $infos = $mailbox->getMailsInfo( $mailsIds );
    print_r( $infos );

    foreach( $mailsIds as $id )
    {
      $email = $mailbox->getMail( $id, false );
      echo 'from-name: '.(string) ($email->fromName ?? $email->fromAddress)."\n";
      echo 'from-email: '.(string) $email->fromAddress."\n";
      echo 'to: '.(string) $email->toString."\n";
      echo 'subject: '.(string) $email->subject."\n";
      echo 'message_id: '.(string) $email->messageId."\n\n";
    }
    
  }
  catch( \PhpImap\Exceptions\ConnectionException $ex )
  {
    echo "IMAP connection failed: " . implode( ",", $ex->getErrors( 'all' ) );
    die();
  }
  */

//   use Noweh\TwitterApi\Client;

//   $twitconf = $conf->load( 'twitter.yml' )->toArray();
//   unset( $twitconf['__path'], $twitconf['__tags'] );

//   $client = new Client( $twitconf );

//   //print_r( $client );

//   $return = $client->tweetLookup()
//     ->showMetrics()
//     ->onlyWithMedias()
//     ->addFilterOnUsernamesFrom( [
//         'NarumonThamma',
//     ], \Noweh\TwitterApi\TweetLookup::OPERATORS['OR'] )
//     ->showUserDetails()
//     ->performRequest()
// ;

// print_r( $return );

echo 'no';