-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPrinter.php
More file actions
51 lines (45 loc) · 994 Bytes
/
Printer.php
File metadata and controls
51 lines (45 loc) · 994 Bytes
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
50
51
<?php
namespace DesignPatterns\Structural\Proxy;
/**
* Printer service can print documents. It can also print the documents scanned
* in advance by a scanner.
*
* @author Vlad Riabchenko <contact@vria.eu>
*/
class Printer
{
/**
* @var Scanner
*/
private $scanner;
/**
* @param Scanner $scanner
*/
public function __construct(Scanner $scanner)
{
$this->scanner = $scanner;
}
/**
* Simply print the document.
*
* @param string $document
*
* @return string
*/
public function printDocument($document)
{
return '<printed>'.$document.'</printed>';
}
/**
* Ask the scanner to scan a document then print this scanned document.
*
* @param string $document
*
* @return string
*/
public function printScannedDocument($document)
{
$scanned = $this->scanner->scanDocument($document);
return $this->printDocument($scanned);
}
}