PHP code example of fullkawa / line-at-cost

1. Go to this page and download the library: Download fullkawa/line-at-cost 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/ */

    

fullkawa / line-at-cost example snippets


use LineAtCost\PlanFactory;
use LineAtCost\Estimator;

$factory = new PlanFactory(PlanFactory::TARGET_2019);

$plan_free = $factory->getInstance(1); // Free plan
$usages_free = ['message_count' => 1000];
$cost_free = Estimator::estimate($plan_free, $usages_free);
$this->assertEquals(0, $cost_free);

$plan_light = $factory->getInstance(2); // Light plan
$usages_light = ['message_count' => 16000];
$cost_light = Estimator::estimate($plan_light, $usages_light);
$this->assertEquals(10000, $cost_light);

$plan_standard = $factory->getInstance(3); // Standard plan
$usages_standard = ['message_count' => 145000];
$cost_standard = Estimator::estimate($plan_standard, $usages_standard);
$this->assertEquals(305000, $cost_standard);

class PlanFactory
{
    const TARGET_ALL = 0;

    /**
     * 2016年6月からの料金プランのみ
     * @var integer
     */
    const TARGET_2016 = 10;

    const PLAN2016FREE_ID = 11; // フリー
    const PLAN2016BASIC_ID = 12; // ベーシック
    const PLAN2016PRO_ID = 13; // プロ(月額21,600円(税込))
    const PLAN2016PRO2_ID = 14; // プロ(月額32,400円(税込))
    const PLAN2016DEVELOPER_ID = 19; // Developer Trial

    /**
     * 2019年春からの料金プランのみ
     * @var integer
     */
    const TARGET_2019 = 20;

    const PLAN2019FREE_ID = 21; // フリー
    const PLAN2019LIGHT_ID = 22; // ライト
    const PLAN2019STANDARD_ID = 23; // スタンダード