KeyedLink.php 986 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

namespace Drupal\d3_sankey_table_group_pp\Model;

use Drupal\d3_sankey\Model\Link;

/**
 * A type of Sankey link that supports strings for source and target.
 */
class KeyedLink extends Link {

  /**
   * The array key of the node to connect from.
   *
   * @var string
   */
  public $source;

  /**
   * The array key of the node to connect to.
   *
   * @var string
   */
  public $target;

  /**
   * A number representing how big the link is.
   *
   * @var numeric
   */
  public $value;

  /**
   * D3SankeyLink constructor.
   *
   * @param string $source
   *   The array index of the node to connect from.
   * @param string $target
   *   The array index of the node to connect to.
   * @param int|float $value
   *   A number representing how big the link is.
   */
  public function __construct($source, $target, $value = 1) {
    $this->source = (string) $source;
    $this->target = (string) $target;
    $this->value = is_numeric($value) ? $value + 0 : 1;
  }

}