FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
Item.php
1 <?php
2 /*
3 Copyright (C) 2014-2015, Siemens AG
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 version 2 as published by the Free Software Foundation.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 
19 namespace Fossology\Lib\Data\Tree;
20 
21 class Item
22 {
23 
25  private $parentId;
26 
28  private $fileId;
29 
31  private $fileMode;
32 
34  private $fileName;
35 
37  private $itemTreeBounds;
38 
39  public function __construct(ItemTreeBounds $itemTreeBounds, $parentId, $fileId,
40  $fileMode, $fileName)
41  {
42  $this->parentId = $parentId;
43  $this->fileId = $fileId;
44  $this->fileMode = $fileMode;
45  $this->fileName = $fileName;
46  $this->itemTreeBounds = $itemTreeBounds;
47  }
48 
52  public function getId()
53  {
54  return $this->itemTreeBounds->getItemId();
55  }
56 
60  public function getParentId()
61  {
62  return $this->parentId;
63  }
64 
68  public function getFileId()
69  {
70  return $this->fileId;
71  }
72 
76  public function getFileMode()
77  {
78  return $this->fileMode;
79  }
80 
84  public function getFileName()
85  {
86  return $this->fileName;
87  }
88 
92  public function getItemTreeBounds()
93  {
94  return $this->itemTreeBounds;
95  }
96 
100  public function isFile()
101  {
102  return !Isartifact($this->fileMode) && !Isdir($this->fileMode) && !Iscontainer($this->fileMode);
103  }
104 
108  public function isContainer()
109  {
110  return Iscontainer($this->fileMode);
111  }
112 
116  public function containsFileTreeItems()
117  {
118  return $this->itemTreeBounds->containsFiles();
119  }
120 
124  public function hasParent()
125  {
126  return $this->parentId !== null;
127  }
128 
129  function __toString()
130  {
131  return "Item(#" . $this->getId() . ", '" . $this->fileName . "')";
132  }
133 }
Iscontainer($mode)
Definition: common-dir.php:49
Isdir($mode)
Definition: common-dir.php:31
Isartifact($mode)
Definition: common-dir.php:40