PHP code example of webgriffe / in-memory-repository

1. Go to this page and download the library: Download webgriffe/in-memory-repository 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/ */

    

webgriffe / in-memory-repository example snippets




namespace MyMovieApp\Tests\Repository\InMemory;

use MyMovieApp\Model\Movie;
use MyMovieApp\Repository\MovieRepositoryInterface;
use Webgriffe\InMemoryRepository\ObjectRepository;

/**
 * @extends ObjectRepository<array-key,Movie>
 */
final class MovieRepository extends ObjectRepository implements MovieRepositoryInterface
{
}

$movieRepository = new \MyMovieApp\Tests\Repository\InMemory\MovieRepository();
$movieRepository->objectCollection->add(new Movie('Rambo'));
$movieRepository->objectCollection->add(new Movie('Top Gun'));

$this->assertCount(2, $movieRepository->findAll());
$this->assertEquals(new Movie('Rambo'), $movieRepository->findOneBy(['title' => 'Rambo']));