PHP code example of tomzx / ditto

1. Go to this page and download the library: Download tomzx/ditto 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/ */

    

tomzx / ditto example snippets


use Ditto\Ditto as d;

// Before PHP 5.5
$ditto = d::make('SomeClass');
// As of PHP 5.5
$ditto = d::make(SomeClass::class);

$ditto->someMethod()->shouldReturn('some value');

// ===
$ditto->someMethod()->shouldReturn('some value');
$ditto->someMethod()->shouldBe('some value');
$ditto->someMethod()->shouldEqual('some value');
$ditto->someMethod()->shouldBeEqualTo('some value');

// ==
$ditto->someMethod()->shouldBeLike('some value');

// instanceof
$ditto->someMethod()->shouldHaveType('SomeType');
$ditto->someMethod()->shouldReturnAnInstanceOf('SomeType');
$ditto->someMethod()->shouldBeAnInstance('SomeType');
$ditto->someMethod()->shouldImplement('SomeType');

// It also works on intrinsic values
$ditto = d::make('this is nice');
$ditto->shouldReturn('this is nice');

$ditto = d::make(15);
$ditto->shouldBe(15);