FOSSology  4.4.0
Open Source License Compliance by Open Source Software
Item.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014-2015 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\Lib\Data\Tree;
9 
10 class Item
11 {
12 
14  private $parentId;
15 
17  private $fileId;
18 
20  private $fileMode;
21 
23  private $fileName;
24 
26  private $itemTreeBounds;
27 
28  public function __construct(ItemTreeBounds $itemTreeBounds, $parentId, $fileId,
29  $fileMode, $fileName)
30  {
31  $this->parentId = $parentId;
32  $this->fileId = $fileId;
33  $this->fileMode = $fileMode;
34  $this->fileName = $fileName;
35  $this->itemTreeBounds = $itemTreeBounds;
36  }
37 
41  public function getId()
42  {
43  return $this->itemTreeBounds->getItemId();
44  }
45 
49  public function getParentId()
50  {
51  return $this->parentId;
52  }
53 
57  public function getFileId()
58  {
59  return $this->fileId;
60  }
61 
65  public function getFileMode()
66  {
67  return $this->fileMode;
68  }
69 
73  public function getFileName()
74  {
75  return $this->fileName;
76  }
77 
81  public function getItemTreeBounds()
82  {
83  return $this->itemTreeBounds;
84  }
85 
89  public function isFile()
90  {
91  return !Isartifact($this->fileMode) && !Isdir($this->fileMode) && !Iscontainer($this->fileMode);
92  }
93 
97  public function isContainer()
98  {
99  return Iscontainer($this->fileMode);
100  }
101 
105  public function containsFileTreeItems()
106  {
107  return $this->itemTreeBounds->containsFiles();
108  }
109 
113  public function hasParent()
114  {
115  return $this->parentId !== null;
116  }
117 
118  function __toString()
119  {
120  return "Item(#" . $this->getId() . ", '" . $this->fileName . "')";
121  }
122 }
Isdir($mode)
Definition: common-dir.php:20
Isartifact($mode)
Definition: common-dir.php:29
Iscontainer($mode)
Definition: common-dir.php:38