PHP code example of jaroslawzielinski / torah

1. Go to this page and download the library: Download jaroslawzielinski/torah library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jaroslawzielinski / torah example snippets




declare(strict_types=1);

Client;
use JaroslawZielinski\Torah\Bible\Service;
use JaroslawZielinski\Torah\Bible\Torah;
use JaroslawZielinski\Torah\Bible\Torah\SiglumFactory;
use JaroslawZielinski\Torah\Bible\TorahValidator;
use JaroslawZielinski\Torah\Translations\Resources;
use JaroslawZielinski\Torah\Bible\Service\Offline\Repository;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$siglum =
    SiglumFactory::create(
        Resources::TORAH_TRANSLATION_KJV,
        Resources::TORAH_BOOKS_J,
        '14',
        '21-24'
    );
$logger = new Logger('Torah');
$logger->pushHandler(new StreamHandler(__DIR__ . '/Torah.log', Logger::INFO));
$onlineClient = new Service\Online\Client($logger, new GuzzleClient());
$offlineClient = new Service\Offline\Client(new Repository());
$options = ['cache' => true];
$torah = new Torah(
    new TorahValidator(),
    new Service($onlineClient, $offlineClient),
    $options
);
$text = $torah->getTextBySiglum($siglum, Torah::LANGUAGE_EN, $contextUp = 2, $contextDown = 3);
if (!empty($text)) {
    echo $text->getOrdered() . '<br/><br/>';
    echo $text->getUnOrdered() . '<br/><br/>';
    echo $text->getDescription() . '<br/><br/>';
} else {
    echo 'Empty!';
    print_r($torah->getErrors());
}




declare(strict_types=1);

Client;
use JaroslawZielinski\Torah\Bible\Service;
use JaroslawZielinski\Torah\Bible\Torah;
use JaroslawZielinski\Torah\Bible\Torah\SiglumFactory;
use JaroslawZielinski\Torah\Bible\TorahValidator;
use JaroslawZielinski\Torah\Translations\Resources;
use JaroslawZielinski\Torah\Bible\Service\Offline\Repository;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$siglum =
    SiglumFactory::create(
        Resources::TORAH_TRANSLATION_BW,
        Resources::TORAH_BOOKS_TB,
        '1',
        '1'
    );
$logger = new Logger('Torah');
$logger->pushHandler(new StreamHandler(__DIR__ . '/Torah.log', Logger::INFO));
$onlineClient = new Service\Online\Client($logger, new GuzzleClient());
$offlineClient = new Service\Offline\Client(new Repository());
$options = ['cache' => true];
$torah = new Torah(
    new TorahValidator(),
    new Service($onlineClient, $offlineClient),
    $options
);
$translation = $torah->getResourceByTranslationCode($siglum->getTranslation());
var_dump($torah->isValid($siglum, $translation, Torah::LANGUAGE_EN));
print_r($torah->getErrors());





declare(strict_types=1);

Client;
use JaroslawZielinski\Torah\Bible\Service;
use JaroslawZielinski\Torah\Bible\Torah;
use JaroslawZielinski\Torah\Bible\TorahValidator;
use JaroslawZielinski\Torah\Translations\Resources;
use JaroslawZielinski\Torah\Bible\Service\Offline\Repository;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('Torah');
$logger->pushHandler(new StreamHandler(__DIR__ . '/Torah.log', Logger::INFO));
$onlineClient = new Service\Online\Client($logger, new GuzzleClient());
$offlineClient = new Service\Offline\Client(new Repository());
$options = ['cache' => true];
$torah = new Torah(
    new TorahValidator(),
    new Service($onlineClient, $offlineClient),
    $options
);
$translation = $torah->getResourceByTranslationCode(Resources::TORAH_TRANSLATION_BT);
$books = $translation->getBooks();
print_r($books[Resources::TANAKH]);
echo '<br/><br/>';
print_r($books[Resources::NEVIIMKETUVIM]);
echo '<br/><br/>';
print_r($books[Resources::BRITHADASHA]);
echo '<br/><br/>';
print_r($books[Resources::EXCEPTIONS]);





declare(strict_types=1);

Client;
use JaroslawZielinski\Torah\Bible\Service;
use JaroslawZielinski\Torah\Bible\Torah;
use JaroslawZielinski\Torah\Bible\TorahValidator;
use JaroslawZielinski\Torah\Translations\Resources;
use JaroslawZielinski\Torah\Bible\Service\Offline\Repository;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('Torah');
$logger->pushHandler(new StreamHandler(__DIR__ . '/Torah.log', Logger::INFO));
$onlineClient = new Service\Online\Client($logger, new GuzzleClient());
$offlineClient = new Service\Offline\Client(new Repository());
$options = ['cache' => true];
$torah = new Torah(
    new TorahValidator(),
    new Service($onlineClient, $offlineClient),
    $options
);
$translation = $torah->getResourceByTranslationCode(Resources::TORAH_TRANSLATION_BT);
$books = $translation->getBooks();
$joz = $books[Resources::TANAKH][Resources::TORAH_BOOKS_JOZ];
print_r($joz[Resources::CHAPTERS]);