Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of PHPUnit.
4
 *
5
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PHPUnit\Framework\MockObject;
11
 
12
use function class_exists;
13
 
14
/**
15
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
16
 */
17
final class MockTrait implements MockType
18
{
19
    /**
20
     * @var string
21
     */
22
    private $classCode;
23
 
24
    /**
25
     * @var class-string
26
     */
27
    private $mockName;
28
 
29
    /**
30
     * @psalm-param class-string $mockName
31
     */
32
    public function __construct(string $classCode, string $mockName)
33
    {
34
        $this->classCode = $classCode;
35
        $this->mockName  = $mockName;
36
    }
37
 
38
    /**
39
     * @psalm-return class-string
40
     */
41
    public function generate(): string
42
    {
43
        if (!class_exists($this->mockName, false)) {
44
            eval($this->classCode);
45
        }
46
 
47
        return $this->mockName;
48
    }
49
 
50
    public function getClassCode(): string
51
    {
52
        return $this->classCode;
53
    }
54
}