remote forking: use the original http/https url in description
[phorkie.git] / src / phorkie / Tool / Info.php
1 <?php
2 namespace phorkie;
3
4 class Tool_Info
5 {
6     public $class;
7
8     public function __construct($class)
9     {
10         $this->class = $class;
11     }
12
13     /**
14      * Format the tool path
15      *
16      * @param File $file
17      *
18      * @return string
19      */
20     public function getLink(File $file)
21     {
22         return $file->getLink('tool', $this->stripPrefix($this->class));
23     }
24
25     /**
26      * Clean namespace from class
27      *
28      * @return string
29      */
30     public function getTitle()
31     {
32         return $this->stripPrefix($this->class);
33     }
34
35     /**
36      * Removes custom namespace prefix
37      *
38      * @param string $class Class of object
39      *
40      * @return string
41      */
42     protected function stripPrefix($class)
43     {
44         $prefix = '\\phorkie\\Tool_';
45         if (substr($class, 0, strlen($prefix)) === $prefix) {
46             return substr($class, strlen($prefix));
47         }
48         return $class;
49     }
50 }
51
52 ?>