1 | <?php |
||
12 | abstract class Publisher implements PublisherContract |
||
13 | { |
||
14 | protected const TELL_DIRECTION_OUT = 'out'; |
||
15 | protected const TELL_DIRECTION_IN = 'in'; |
||
16 | protected const TELL_DIRECTION_FLAT = 'flat'; |
||
17 | protected const TELL_DIRECTION_NONE = 'none'; |
||
18 | |||
19 | private const DIRECTORY_READY_MODE = 0777; |
||
20 | |||
21 | /** |
||
22 | * Calling command if running in console. |
||
23 | * |
||
24 | * @var Command |
||
25 | */ |
||
26 | protected $callingCommand; |
||
27 | |||
28 | /** |
||
29 | * @var FilesystemContract |
||
30 | */ |
||
31 | protected $filesystem; |
||
32 | |||
33 | /** |
||
34 | * @var LoggerContract |
||
35 | */ |
||
36 | protected $logger; |
||
37 | |||
38 | /** |
||
39 | * @var float |
||
40 | */ |
||
41 | private $startTime; |
||
42 | |||
43 | /** |
||
44 | * Publisher constructor. |
||
45 | * |
||
46 | * @param FilesystemContract $filesystem |
||
47 | * @param LoggerContract $logger |
||
48 | */ |
||
49 | public function __construct(FilesystemContract $filesystem, LoggerContract $logger) |
||
55 | |||
56 | /** |
||
57 | * @return string |
||
58 | */ |
||
59 | protected function getExecutionTime(): string |
||
63 | |||
64 | /** |
||
65 | * Print to console or screen. |
||
66 | * |
||
67 | * @param string $text |
||
68 | * @param string $direction in|out |
||
69 | * |
||
70 | * @return string |
||
71 | */ |
||
72 | protected function tell($text, $direction = self::TELL_DIRECTION_OUT) |
||
97 | |||
98 | /** |
||
99 | * Ensure documentation resource directory exists and is writable. |
||
100 | * |
||
101 | * @param string $directory |
||
102 | * |
||
103 | * @return bool |
||
104 | */ |
||
105 | protected function readyResourceDirectory(string $directory): bool |
||
113 | |||
114 | protected function setExecutionStartTime(): void |
||
118 | |||
119 | /** |
||
120 | * Get seconds since a micro-time start-time. |
||
121 | * |
||
122 | * @param float $startTime start time in microseconds |
||
123 | * |
||
124 | * @return string seconds since, to 2 decimal places |
||
125 | */ |
||
126 | private function secondsSince(float $startTime): string |
||
135 | } |
||
136 |