コード例 #1
0
ファイル: Links.php プロジェクト: chippyash/simple-accounts
 /**
  * Constructor
  *
  * Takes array of Links and creates internal structure of associated array using
  * each Entry name as the key
  *
  * @param array $values Array[Link,...] of initial control account entries
  */
 public function __construct(array $values = [])
 {
     parent::__construct(\array_combine(\array_map(function (Link $link) {
         return $link->getName()->get();
     }, $values), $values), 'SAccounts\\Control\\Link');
 }
コード例 #2
0
ファイル: fetch.php プロジェクト: widmogrod/manga-scraper
    });
}
//var_dump(download(new ChapterPage(
//    new Chapter('Sudome', 'http://www.mangatown.com/manga/sundome/v01/c002/3.html'),
//    new Page('03', 'http://www.mangatown.com/manga/sundome/v01/c002/3.html'),
//    new PageImage('http://a.mangatown.com/store/manga/3412/01-002.0/compressed/002.jpg?v=51215960241')
//)));
//die;
IO\getArgs()->map(get(0))->map(function (Maybe\Maybe $argument) {
    return $argument->map(function ($mangaUrl) {
        var_dump('started ', $mangaUrl);
        $mangaData = fetchMangaData($mangaUrl);
        var_dump('manga data ready');
        $afterDownload = $mangaData->map(f\map(f\map(download)));
        var_dump('manga first run');
        $afterDownload->map(function (Collection $collection) {
            $ttl = 2;
            do {
                var_dump('re-download');
                $toRetry = f\filter(function (Maybe\Maybe $maybe) {
                    return $maybe->extract() instanceof Either\Left;
                }, $collection);
                $count = count($toRetry);
                $collection = Collection::of($toRetry)->map(function ($a) use(&$ttl, $count) {
                    var_dump('retry', $ttl, $count);
                    return failed($a, $ttl);
                });
            } while (count($toRetry) > 0);
        });
    });
})->run();
コード例 #3
0
ファイル: Entries.php プロジェクト: chippyash/simple-accounts
 /**
  * Constructor
  *
  * Enforces Collection to be of type SAccounts\Transaction\Entry
  *
  * @param array $value Associative array of data to set
  */
 public function __construct(array $value = [])
 {
     parent::__construct($value, 'SAccounts\\Transaction\\Entry');
 }
コード例 #4
0
ファイル: Collection.php プロジェクト: chippyash/monad
 /**
  * Return a Collection that is the union of the values of this Collection
  * and the other Collection using the keys for comparison
  *
  * @param Collection $other
  *
  * @return Collection
  */
 public function kUnion(Collection $other)
 {
     return new static($this->getArrayCopy() + $other->getArrayCopy(), $this->type);
 }
コード例 #5
0
ファイル: utils.php プロジェクト: widmogrod/manga-scraper
function xpath(\DOMDocument $doc, $path)
{
    $xpath = new \DOMXPath($doc);
    $elements = $xpath->query($path);
    return $elements->length ? Maybe\just(Collection::of($elements)) : Maybe\nothing();
}
コード例 #6
0
ファイル: CollectionTest.php プロジェクト: chippyash/monad
 public function testYouCanFlipACollection()
 {
     $s1 = Collection::create([1, 2, 3, 6, 7])->flip()->toArray();
     $this->assertEquals([1 => 0, 2 => 1, 3 => 2, 6 => 3, 7 => 4], $s1);
 }