Issues (34)

src/Util/SupplierUtil.php (2 issues)

1
<?php
2
3
namespace Graphp\Util;
4
5
use Graphp\Edge\DefaultEdge;
6
use Graphp\Edge\DefaultWeightedEdge;
7
8
/**
9
 * Class SupplierUtil
10
 *
11
 * @package Graphp\Util
12
 */
13
class SupplierUtil
14
{
15
    /**
16
     * Supplier constants
17
     */
18
    public const DEFAULT_EDGE_SUPPLIER = DefaultEdge::class;
19
    public const DEFAULT_WEIGHTED_EDGE_SUPPLIER = DefaultWeightedEdge::class;
20
21
    /**
22
     * Create an edge supplier
23
     *
24
     * @param string $className - edge class name
25
     *
26
     * @return SupplierInterface
27
     */
28 44
    public static function createSupplier(string $className): SupplierInterface
29
    {
30 44
        return new Supplier($className);
31
    }
32
33
    /**
34
     * Create a default edge supplier
35
     *
36
     * @return DefaultEdge
37
     */
38 1
    public static function createDefaultEdgeSupplier(): SupplierInterface
39
    {
40 1
        return self::createSupplier(DefaultEdge::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return self::createSuppl...dge\DefaultEdge::class) returns the type Graphp\Util\Supplier which is incompatible with the documented return type Graphp\Edge\DefaultEdge.
Loading history...
41
    }
42
43
    /**
44
     * Create a default weighted edge supplier
45
     *
46
     * @return DefaultWeightedEdge
47
     */
48 1
    public static function createDefaultWeightedEdgeSupplier(): SupplierInterface
49
    {
50 1
        return self::createSupplier(DefaultWeightedEdge::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return self::createSuppl...ultWeightedEdge::class) returns the type Graphp\Util\Supplier which is incompatible with the documented return type Graphp\Edge\DefaultWeightedEdge.
Loading history...
51
    }
52
53
    /**
54
     * Create an integer supplier
55
     *
56
     * @return SupplierInterface
57
     */
58 1
    public static function createIntegerSupplier(int $start = 0): SupplierInterface
59
    {
60 1
        return new IntegerSupplier($start);
61
    }
62
63
    /**
64
     * Create a string supplier
65
     *
66
     * @return SupplierInterface
67
     */
68 1
    public static function createStringSupplier(int $start = 0): SupplierInterface
69
    {
70 1
        return new StringSupplier($start);
71
    }
72
}
73